home *** CD-ROM | disk | FTP | other *** search
- <TITLE>nntplib -- Python library reference</TITLE>
- Next: <A HREF="../u/urlparse" TYPE="Next">urlparse</A>
- Prev: <A HREF="../g/gopherlib" TYPE="Prev">gopherlib</A>
- Up: <A HREF="../i/internet_and_www" TYPE="Up">Internet and WWW</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H1>10.6. Standard Module <CODE>nntplib</CODE></H1>
- This module defines the class <CODE>NNTP</CODE> which implements the client
- side of the NNTP protocol. It can be used to implement a news reader
- or poster, or automated news processors. For more information on NNTP
- (Network News Transfer Protocol), see Internet RFC 977.
- <P>
- Here are two small examples of how it can be used. To list some
- statistics about a newsgroup and print the subjects of the last 10
- articles:
- <P>
- @small{
- <UL COMPACT><CODE>>>> s = NNTP('news.cwi.nl')<P>
- >>> resp, count, first, last, name = s.group('comp.lang.python')<P>
- >>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last<P>
- Group comp.lang.python has 59 articles, range 3742 to 3803<P>
- >>> resp, subs = s.xhdr('subject', first + '-' + last)<P>
- >>> for id, sub in subs[-10:]: print id, sub<P>
- ... <P>
- 3792 Re: Removing elements from a list while iterating...<P>
- 3793 Re: Who likes Info files?<P>
- 3794 Emacs and doc strings<P>
- 3795 a few questions about the Mac implementation<P>
- 3796 Re: executable python scripts<P>
- 3797 Re: executable python scripts<P>
- 3798 Re: a few questions about the Mac implementation <P>
- 3799 Re: PROPOSAL: A Generic Python Object Interface for Python C Modules<P>
- 3802 Re: executable python scripts <P>
- 3803 Re: POSIX wait and SIGCHLD<P>
- >>> s.quit()<P>
- '205 news.cwi.nl closing connection. Goodbye.'<P>
- >>> <P>
- </CODE></UL>
- }
- <P>
- To post an article from a file (this assumes that the article has
- valid headers):
- <P>
- <UL COMPACT><CODE>>>> s = NNTP('news.cwi.nl')<P>
- >>> f = open('/tmp/article')<P>
- >>> s.post(f)<P>
- '240 Article posted successfully.'<P>
- >>> s.quit()<P>
- '205 news.cwi.nl closing connection. Goodbye.'<P>
- >>> <P>
- </CODE></UL>
- The module itself defines the following items:
- <P>
- <DL><DT><B>NNTP</B> (<VAR>host</VAR>[, <VAR>port</VAR>]) -- function of module nntplib<DD>
- Return a new instance of the <CODE>NNTP</CODE> class, representing a
- connection to the NNTP server running on host <VAR>host</VAR>, listening at
- port <VAR>port</VAR>. The default <VAR>port</VAR> is 119.
- </DL>
- <DL><DT><B>error_reply</B> -- exception of module nntplib<DD>
- Exception raised when an unexpected reply is received from the server.
- </DL>
- <DL><DT><B>error_temp</B> -- exception of module nntplib<DD>
- Exception raised when an error code in the range 400--499 is received.
- </DL>
- <DL><DT><B>error_perm</B> -- exception of module nntplib<DD>
- Exception raised when an error code in the range 500--599 is received.
- </DL>
- <DL><DT><B>error_proto</B> -- exception of module nntplib<DD>
- Exception raised when a reply is received from the server that does
- not begin with a digit in the range 1--5.
- </DL>
- <H2>Menu</H2><DL COMPACT>
- <DT><A HREF="../n/nntp_objects" TYPE=Menu>NNTP Objects</A>
- <DD></DL>
-