nntplib

An NNTP client class based on RFC 977: Network News Transfer Protocol.

Example:

>>> from nntplib import NNTP
>>> s = NNTP('news')
>>> resp, count, first, last, name = s.group('comp.lang.python')
>>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
Group comp.lang.python has 51 articles, range 5770 to 5821
>>> resp, subs = s.xhdr('subject', first + '-' + last)
>>> resp = s.quit()
>>>

Here ‘resp’ is the server response line. Error responses are turned into exceptions.

To post an article from a file: >>> f = open(filename, ‘r’) # file containing article, including header >>> resp = s.post(f) >>>

For descriptions of all methods, read the comments in the code below. Note that all arguments and return values representing article numbers are strings, not numbers, since they are rarely used for calculations.

Classes

NNTP(host[, port, user, password, ...])

Exceptions

NNTPDataError(*args) Error in response data
NNTPError(*args) Base class for all nntplib exceptions
NNTPPermanentError(*args) 5xx errors
NNTPProtocolError(*args) Response does not begin with [1-5]
NNTPReplyError(*args) Unexpected [123]xx reply
NNTPTemporaryError(*args) 4xx errors
error_data alias of NNTPDataError
error_perm alias of NNTPPermanentError
error_proto alias of NNTPProtocolError
error_reply alias of NNTPReplyError
error_temp alias of NNTPTemporaryError