Created
August 22, 2019 14:45
-
-
Save davidmintz/0a1c63be0973324326ffbcc4a16680a0 to your computer and use it in GitHub Desktop.
quick and dirty html extraction for .eml files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# useful for development and testing, this gets the html payload from | |
# .eml files (e.g., as produced by Zend\Mail) and prints it to STDOUT | |
from email import parser; | |
import argparse; | |
args = argparse.ArgumentParser() | |
args.add_argument("filename", help="path to .eml file") | |
filename = args.parse_args().filename | |
data = open(filename) | |
msg = parser.Parser().parse(data) | |
html = msg.get_payload()[1] | |
thing = str(html.get_payload(decode=True)) | |
print(thing.replace('\\n','\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment