nntplib question

Alex Martelli aleax at aleax.it
Sun Feb 23 15:14:15 EST 2003


L. B. wrote:

> Hi all,
> 
> i'm building a trivial cgi-newsreader... at this stage i'm just
> hacking around the nntplib module trying to understand how it works.
> 
> I didn't understand how to retrieve the message body because there is
> not a "body" header in usenet messages

Right -- the body is what comes AFTER all headers.  Therefore,
the xhdr extension (which you're using to retrieve headers) does
NOT save the bodies... so you can't get them that way!


> Till now i've just produced the code you'll find at the link below...
> could you please help me understand how to extract the body having the
> article number and or message-id?
> 
> http://www.bolognini.net/python.html

msg_body = cnn.body(nart)

should do it, assuming "nart" is the post id (including < and >
characters around it) or the post number within the group (a
number-within-the-group represented as a decimal string).

For ample docs on all methods of NNTP objects:
http://www.python.org/doc/current/lib/nntp-objects.html

Best usage examples I've seen for nntplib are in Steve Holden's
"Python Web Programming".


Alex





More information about the Python-list mailing list