识别纯文本和HTML电子邮件中引用文本的库。
quotequail的Python项目详细描述
识别纯文本和HTML电子邮件中引用文本的库。 quotequeail没有强制依赖项,但是使用html方法需要 libxml。
(对这样的项目感兴趣?Close.io正在寻找great engineers加入我们的团队)
简介
QUOTEQUAIL附带下列功能,详细说明 在quotequemail的__init__.py中。
- quote(text):接受纯文本消息作为参数,返回 元组。元组的第一个参数表示文本是否应该 默认展开。第二个参数是未修改的对应 文本。
- quote_html(html):类似于quote(),但将HTML消息作为 争论。
- unwrap(text):如果传递的文本是转发消息的文本体, 返回一个回复或包含引用文本的字典,其中包含 键入(reply/forward/quote),在包装的顶部/底部的文本 消息、任何解析的头和包装消息的文本。
- unwrap_html(text):类似于unwrap(),但将HTML消息作为 争论。
示例
In[1]:importquotequailIn[2]:quotequail.quote("""Hello world. On 2012-10-16 at 17:02 , Someone <someone@example.com> wrote: > Some quoted text """)Out[2]:[(True,'Hello world.\n\nOn 2012-10-16 at 17:02 , Someone <someone@example.com> wrote:'),(False,'\n> Some quoted text\n')]In[3]:quotequail.unwrap("""Hello Begin forwarded message: > From: "Some One" <some.one@example.com> > Date: 1. August 2011 23:28:15 GMT-07:00 > To: "Other Person" <other@example.com> > Subject: AW: AW: Some subject > > Original text Text bottom """))Out[3]:{'date':'1. August 2011 23:28:15 GMT-07:00','from':'"Some One" <some.one@example.com>','subject':'AW: AW: Some subject','text':'Original text','text_bottom':'Text bottom','text_top':'Hello','to':'"Other Person" <other@example.com>','type':'forward'}