Compare commits
2 Commits
584a5e82b1
...
59b478d854
Author | SHA1 | Date | |
---|---|---|---|
59b478d854 | |||
220b102830 |
@ -22,6 +22,11 @@ def extract_and_convert_email(message, output_file_base, i):
|
||||
try:
|
||||
payload = part.get_payload(decode=True).decode(charset, errors='replace')
|
||||
soup = BeautifulSoup(payload, 'html.parser')
|
||||
# Nettoyage de l'HTML
|
||||
attr_whitelist = ("style")
|
||||
for tag in soup.findAll(True):
|
||||
for attr in [attr for attr in tag.attrs if attr not in attr_whitelist]:
|
||||
del tag[attr]
|
||||
html_content = str(soup)
|
||||
|
||||
# Extraction de la date et formatage ISO
|
||||
@ -38,11 +43,11 @@ def extract_and_convert_email(message, output_file_base, i):
|
||||
logging.warning(f"Format de date invalide: {date_header}")
|
||||
output_file = os.path.join(output_file_base, f"email_{i}") # Nom par défaut si date invalide
|
||||
date_simple = "<i>date inconnue</i>"
|
||||
html_header = "<p><ul>"
|
||||
html_header = "<div style=\"border: thick double black;\"><ul>"
|
||||
html_header += f"<li>De : {from_header}</li>"
|
||||
html_header += f"<li>À : {to_header}</li>"
|
||||
html_header += f"<li>Date : {date_simple}</li>"
|
||||
html_header += "</ul><br /></p>"
|
||||
html_header += "</ul><br /></div>"
|
||||
# Conversion en PDF
|
||||
try:
|
||||
html_content = html_header + html_content
|
||||
|
Loading…
x
Reference in New Issue
Block a user