我使用imaplib
从Gmail中检索电子邮件,并将其输入Beautifulsoup
来解析电子邮件的HTML代码。在
M = imaplib.IMAP4_SSL('imap.gmail.com')
M.select('Inbox')
rv, data = M.SEARCH(None, '(FROM "foo@bar.com")')
if rv == 'OK':
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
html = data[0][1].strip()
问题:为什么html
包含这么多=0D\r\n
的出现?它们是什么?我们应该完全删除它们还是用另一个字符串替换它们?在
示例:
^{pr2}$更新
尝试分析为quoted-printible
,使用
html = html.decode('utf-8')
html = email.message_from_string(html)
它清理了html
好多了,但是在几乎每一行的末尾仍然有{
还有字符串3D
出现在=
之后。。。在
</tr>=0D
<tr>=0D
<td height=3D"12"></td>=0D
</tr>=0D
<tr></tr>=0D
<tr>=0D
<td class=3D"height35" height=3D"50"></td>=0D
</tr>=0D
</tbody>=0D
目前没有回答
相关问题 更多 >
编程相关推荐