ich versuche mithilfe von BeautifulSoup eine E-Mail ansehnlicher aussehen zu lassen, jedoch bekomme ich diese Fehlermeldung stattdessen ausgespuckt.
Code: Alles auswählen
Traceback (most recent call last):
File "C:/Users/Oli/Google Drive/Programmieren/IF/imap.py", line 42, in <module>
soup = BeautifulSoup(raw, "lxml")
File "C:\Users\Oli\Google Drive\Programmieren\IF\venv\lib\site-packages\bs4\__init__.py", line 278, in __init__
markup, from_encoding, exclude_encodings=exclude_encodings)):
File "C:\Users\Oli\Google Drive\Programmieren\IF\venv\lib\site-packages\bs4\builder\_lxml.py", line 148, in prepare_markup
markup, try_encodings, is_html, exclude_encodings)
File "C:\Users\Oli\Google Drive\Programmieren\IF\venv\lib\site-packages\bs4\dammit.py", line 227, in __init__
self.markup, self.sniffed_encoding = self.strip_byte_order_mark(markup)
File "C:\Users\Oli\Google Drive\Programmieren\IF\venv\lib\site-packages\bs4\dammit.py", line 279, in strip_byte_order_mark
if (len(data) >= 4) and (data[:2] == b'\xfe\xff') \
File "C:\Users\Oli\AppData\Local\Programs\Python\Python37-32\lib\email\message.py", line 391, in __getitem__
return self.get(name)
File "C:\Users\Oli\AppData\Local\Programs\Python\Python37-32\lib\email\message.py", line 468, in get
name = name.lower()
AttributeError: 'slice' object has no attribute 'lower'
Code: Alles auswählen
import imaplib, email
from bs4 import BeautifulSoup
user = 'XXXX'
password = 'XXX'
imap_url = 'imap.gmx.net'
con = imaplib.IMAP4_SSL(imap_url)
con.login(user, password)
con.select('INBOX')
result, data = con.fetch(b'11', '(RFC822)')
raw = email.message_from_bytes(data[0][1])
soup = BeautifulSoup(raw, "html.parser")