So far in this chapter, we have focused on Python’s FTP and email processing
tools and have met a handful of client-side scripting modules along
urllib, and so on. This set is
representative of Python’s client-side library tools for transferring
and processing information over the Internet, but it’s not at all
A more or less comprehensive list of Python’s Internet-related modules appears at the start of the previous chapter. Among other things, Python also includes client-side support libraries for Internet news, Telnet, HTTP, XML-RPC, and other standard protocols. Most of these are analogous to modules we’ve already met—they provide an object-based interface that automates the underlying sockets and message structures.
For instance, Python’s
nntplib module supports the client-side
interface to NNTP—the Network News Transfer Protocol—which is used for
reading and posting articles to Usenet newsgroups on the Internet.
Like other protocols, NNTP runs on top of sockets and merely defines a
standard message protocol; like other modules,
nntplib hides most of the protocol details
and presents an object-based interface to Python scripts.
We won’t get into full protocol details here, but in brief, NNTP servers store a range of articles on the server machine, usually in a flat-file database. If you have the domain or IP name of a server machine that runs an NNTP server program listening on the NNTP port, ...