In Table 20.7, we present a list of modules which you may find useful for Web development. You may also wish to look at the Internet Client Programming in Chapter 17, as well as the Web services section of Chapter 23 for other modules that may be useful for Web applications.
Table 20.7. Web Programming Related Modules
Module/Package | Description |
---|
Web Applications | |
cgi | Gets Common Gateway Interface (CGI) form data |
cgitb[c] | Handles CGI tracebacks |
htmllib | Older HTML parser for simple HTML files; HTML-Parser class extends from sgmllib.SGMLParser |
HTMLparser[c] | Newer non-SGML-based parser for HTML and XHTML |
htmlentitydefs | HTML general entity definitions |
Cookie | Server-side cookies for HTTP state management |
cookielib[e] | Cookie-handling classes for HTTP clients |
webbrowser[b] | Controller: launches Web documents in a browser |
sgmllib | Parses simple SGML files |
robotparser[a] | Parses robots.txt files for URL "fetchability" analysis |
httplib[a] | Used to create HTTP clients |
XML Processing | |
xmllib | (Outdated/deprecated) original simple XML parser |
xml[b] | XML package featuring various parsers (some below) |
xml.sax[b] | Simple API for XML (SAX) SAX2-compliant XML parser |
xml.dom[b] | Document Object Model [DOM] XML parser |
xml.etree[f] | Tree-oriented XML parser based on the Element flexible container object |
xml.parsers.expat[b] | Interface to the non-validating Expat XML parser |
xmlrpclib[c] | Client support for XML Remote Procedure Call (RPC) via HTTP |
XML Processing | |
SimpleXMLRPCServer[c] | Basic framework for Python XML-RPC servers |
DocXMLRPCServer[d] | Framework for self-documenting XML-RPC servers |
Web Servers | |
BaseHTTPServer | Abstract class with which to develop Web servers |
SimpleHTTPServer | Serve the simplest HTTP requests (HEAD and GET) |
CGIHTTPServer | In addition to serving Web files like SimpleHTTPServers, can also process CGI (HTTP POST) requests |
wsgiref[f] | Standard interface between Web servers and Python Web application |
3rd party packages (not in standard library) |
HTMLgen | CGI helper converts Python objects into valid HTML http://starship.python.net/crew/friedrich/HTMLgen/html/main.html |
BeautifulSoup | HTML and XML parser and screen-scraper http://crummy.com/software/BeautifulSoup |
Mail Client Protocols |
poplib | Use to create POP3 clients |
imaplib | Use to create IMAP4 clients |
Mail and MIME Processing and Data Encoding Formats |
email[c] | Package for managing e-mail messages, including MIME and other RFC2822-based message |
mailbox | Classes for mailboxes of e-mail messages |
mailcap | Parses mailcap files to obtain MIME application delegations |
Mail and MIME Processing and Data Encoding Formats |
mimetools | Provides functions for manipulating MIME-encoded messages |
mimetypes | Provides MIME-type associations |
MimeWriter | Generates MIME-encoded multipart files |
multifile | Can parse multipart MIME-encoded files |
quopri | En-/decodes data using quoted-printable encoding |
rfc822 | Parses RFC822-compliant e-mail headers |
smtplib | Uses to create SMTP (Simple Mail Transfer Protocol) clients |
base64 | En-/decodes data using base64 encoding |
binascii | En-/decodes data using base64, binhex, or uu (modules) |
binhex | En-/decodes data using binhex4 encoding |
uu | En-/decodes data using uuencode encoding |
Internet Protocols | |
httplib[a] | Used to create HTTP clients |
ftplib | Used to create FTP (File Transfer Protocol) clients |
gopherlib | Used to create Gopher clients |
telnetlib | Used to create Telnet clients |
nntplib | Used to create NNTP (Network News Transfer Protocol [Usenet]) clients |