How do I Extract Attachment from Newsgroup Message
Dave Borne
dborne at gmail.com
Thu May 31 11:03:05 EDT 2007
> I looked for a solution
> with mimetools (the way I'd approach it for email) but found nothing.
...
> <D8PANKEG1 at news.ap.org>', 'Content-Type: Multipart/Mixed;', '
> boundary="------------Boundary-00=_A5NJCP3FX6Y5BI3BH890"', 'Date: Thu,
...
Playing with
data = n.article('116431')[3]
and email.message_from_string, there seems to be a problem with the
content type being split up. I was able to get a multipart message by
using
msg = email.message_from_string('\n'.join(data).replace(';\n', ';'))
(and adding an ending boundary to your sample data).
This is a bit hackish and could cause problems if there are
semicolons inside the message body (no warranties expressed or
implied, etc.)
Hope this helps,
-Dave
More information about the Python-list
mailing list