2006年07月04日 星期二 11:52
学习一下,先:)
BTW,在usenet.xml中:
应该是 。
_____
From: python-chinese-bounces at lists.python.cn
[mailto:python-chinese-bounces at lists.python.cn] On Behalf Of netkiller
Sent: 2006年7月4日 11:33
To: python-chinese at lists.python.cn
Subject: Re: [python-chinese] 请教读取email的办法
你用现有的库好些.性能要好很多.
我这段正则性能差.
我做的usenet 原码在我的svn上.
http://opensvn.csie.org/netkiller/Workspace/Python/src/
----- Original Message -----
From: liguopeng liguopeng at tsinghua.org.cn>
To: python-chinese at lists.python.cn
Sent: Tuesday, July 04, 2006 11:24 AM
Subject: RE: [python-chinese] 请教读取email的办法
我对这个比较有兴趣。不过python的经验比较少,呵呵。
C++不错,MIME, POP3, SMTP等也比较熟。
_____
From: python-chinese-bounces at lists.python.cn
[mailto:python-chinese-bounces at lists.python.cn] On Behalf Of netkiller
Sent: 2006年7月4日 10:48
To: python-chinese at lists.python.cn
Subject: Re: [python-chinese] 请教读取email的办法
正责.给你参考.我在写一个基于数据库的新闻组..你有兴趣吗?
你的需求我很早以前做过..因为硬盘坏了,例子没了..你可以去网上找找我的贴
子.
def parseArticle(self,data):
"""
From: "NEO" <openunix at 163.com>
Newsgroups: cn.test
Subject: test
Date: Fri, 30 Jun 2006 17:14:17 +0800
Lines: 3
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
"""
#[a-zA-z0-9]+@[a-zA-z0-9]+.[a-zA-z]+
matchs = (
('From', r'From: (".+" <.+>)\r\n'),
('Newsgroups', r'Newsgroups: (.+)\r\n'),
('Subject', r'Subject: (.+)\r\n'),
('Date', r'Date: (.+)\r\n'),
('Lines', r'Lines: (.+)\r\n'),
('X-Priority', r'X-Priority: (.+)\r\n'),
('X-MSMail-Priority', r'X-MSMail-Priority: (.+)\r\n'),
('X-Newsreader', r'X-Newsreader: (.+)\r\n'),
('X-MimeOLE', r'X-MimeOLE: (.+)\r\n'),
('X-RFC2646', r'X-RFC2646: (.+)\r\n'),
('Xref', r'Xref: (.+)\r\n'),
('Body', r'\r\n\r\n(.+)\r\n\r\n\r\n')
)
parse = {}
for head, value in matchs:
digs = re.compile(value,re.IGNORECASE)
for test in digs.findall(data):
parse[head] = test
# print parse
return parse
----- Original Message -----
From: lei zhenlin ray8866 at gmail.com>
To: python-chinese at lists.python.cn
Sent: Tuesday, July 04, 2006 9:56 AM
Subject: [python-chinese] 请教读取email的办法
大家好!
我现需要解决这样一个问题:自动收取POP3邮件,将From、To、主题、信件内容保存到
数据库中,将附件保存到文件中,请问如何实现最方便?
我的初步思路是,尽量使用现有的软件,如在Linux下,收meil有fetchmail,收到的
mail存放在mbox邮箱中,如何解析每一封邮件就是我要实现的最关键问题了。在
windows下,我发现Thundbird邮件客户端的邮箱也是mbox格式的,所以可以用
Thundbird自动收邮件,但如何自动解析邮件也是关键所在。
现在的邮件客户端都需要手工来查看邮件内容、另存附件等操作,不能满足我的自动解
析邮件内容的需求。
我查看了Python的mailbox、email等模块,发现是可以解析mbox邮箱的,但没有搞明白
到底如何实现。请教python-chinese的朋友们,是否能够帮助我解决一下这个问题呢?
非常感谢!
--
----------------------------------------
Lei zhenlin
_____
_______________________________________________
python-chinese
Post: send python-chinese at lists.python.cn
Subscribe: send subscribe to python-chinese-request at lists.python.cn
Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
_____
_______________________________________________
python-chinese
Post: send python-chinese at lists.python.cn
Subscribe: send subscribe to python-chinese-request at lists.python.cn
Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060704/8ed02b7c/attachment-0001.html
2006年07月04日 星期二 12:34
Use-Case-用例实现规约:这个XML目前没有使用.那天玩python DOM时测试用的. ----- Original Message ----- From: liguopeng To: python-chinese at lists.python.cn Sent: Tuesday, July 04, 2006 11:52 AM Subject: RE: [python-chinese] 请教读取email的办法 <用例名称> 学习一下,先:) BTW,在usenet.xml中:应该是 。 ------------------------------------------------------------------------------ From: python-chinese-bounces at lists.python.cn [mailto:python-chinese-bounces at lists.python.cn] On Behalf Of netkiller Sent: 2006年7月4日 11:33 To: python-chinese at lists.python.cn Subject: Re: [python-chinese] 请教读取email的办法 你用现有的库好些.性能要好很多. 我这段正则性能差. 我做的usenet 原码在我的svn上. http://opensvn.csie.org/netkiller/Workspace/Python/src/ ----- Original Message ----- From: liguopeng To: python-chinese at lists.python.cn Sent: Tuesday, July 04, 2006 11:24 AM Subject: RE: [python-chinese] 请教读取email的办法 我对这个比较有兴趣。不过python的经验比较少,呵呵。 C++不错,MIME, POP3, SMTP等也比较熟。 ---------------------------------------------------------------------------- From: python-chinese-bounces at lists.python.cn [mailto:python-chinese-bounces at lists.python.cn] On Behalf Of netkiller Sent: 2006年7月4日 10:48 To: python-chinese at lists.python.cn Subject: Re: [python-chinese] 请教读取email的办法 正责.给你参考.我在写一个基于数据库的新闻组..你有兴趣吗? 你的需求我很早以前做过..因为硬盘坏了,例子没了..你可以去网上找找我的贴子. def parseArticle(self,data): """ From: "NEO" <openunix at 163.com> Newsgroups: cn.test Subject: test Date: Fri, 30 Jun 2006 17:14:17 +0800 Lines: 3 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original """ #[a-zA-z0-9]+@[a-zA-z0-9]+.[a-zA-z]+ matchs = ( ('From', r'From: (".+" <.+>)\r\n'), ('Newsgroups', r'Newsgroups: (.+)\r\n'), ('Subject', r'Subject: (.+)\r\n'), ('Date', r'Date: (.+)\r\n'), ('Lines', r'Lines: (.+)\r\n'), ('X-Priority', r'X-Priority: (.+)\r\n'), ('X-MSMail-Priority', r'X-MSMail-Priority: (.+)\r\n'), ('X-Newsreader', r'X-Newsreader: (.+)\r\n'), ('X-MimeOLE', r'X-MimeOLE: (.+)\r\n'), ('X-RFC2646', r'X-RFC2646: (.+)\r\n'), ('Xref', r'Xref: (.+)\r\n'), ('Body', r'\r\n\r\n(.+)\r\n\r\n\r\n') ) parse = {} for head, value in matchs: digs = re.compile(value,re.IGNORECASE) for test in digs.findall(data): parse[head] = test # print parse return parse ----- Original Message ----- From: lei zhenlin To: python-chinese at lists.python.cn Sent: Tuesday, July 04, 2006 9:56 AM Subject: [python-chinese] 请教读取email的办法 大家好! 我现需要解决这样一个问题:自动收取POP3邮件,将From、To、主题、信件内容保存到数据库中,将附件保存到文件中,请问如何实现最方便? 我的初步思路是,尽量使用现有的软件,如在Linux下,收meil有fetchmail,收到的mail存放在mbox邮箱中,如何解析每一封邮件就是我要实现的最关键问题了。在windows下,我发现Thundbird邮件客户端的邮箱也是mbox格式的,所以可以用Thundbird自动收邮件,但如何自动解析邮件也是关键所在。 现在的邮件客户端都需要手工来查看邮件内容、另存附件等操作,不能满足我的自动解析邮件内容的需求。 我查看了Python的mailbox、email等模块,发现是可以解析mbox邮箱的,但没有搞明白到底如何实现。请教python-chinese的朋友们,是否能够帮助我解决一下这个问题呢? 非常感谢! -- ---------------------------------------- Lei zhenlin -------------------------------------------------------------------------- _______________________________________________ python-chinese Post: send python-chinese at lists.python.cn Subscribe: send subscribe to python-chinese-request at lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese ---------------------------------------------------------------------------- _______________________________________________ python-chinese Post: send python-chinese at lists.python.cn Subscribe: send subscribe to python-chinese-request at lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese ------------------------------------------------------------------------------ _______________________________________________ python-chinese Post: send python-chinese at lists.python.cn Subscribe: send subscribe to python-chinese-request at lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060704/292a80d7/attachment-0001.htm
Zeuux © 2025
京ICP备05028076号