Standard Module htmllib

htmllib

This module defines a class which can serve as a base for parsing text files formatted in the HyperText Mark-up Language (HTML). The class is not directly concerned with I/O — it must be provided with input in string form via a method, and makes calls to methods of a ``formatter'' object in order to produce output. The HTMLParser class is designed to be used as a base class for other classes in order to add functionality, and allows most of its methods to be extended or overridden. In turn, this class is derived from and extends the SGMLParser class defined in module sgmllib. Two implementations of formatter objects are provided in the formatter module; refer to the documentation for that module for information on the formatter interface. sgmllib SGMLParser formatter

The following is a summary of the interface defined by sgmllib.SGMLParser:

The module defines a single class:


\begin{funcdesc}{HTMLParser}{formatter}
This is the basic HTML parser class. It ...
...nes
handlers for all HTML 2.0 and many HTML 3.0 and 3.2 elements.
\end{funcdesc}

In addition to tag methods, the HTMLParser class provides some additional methods and instance variables for use within tag methods.


\begin{datadesc}{formatter}
This is the formatter instance associated with the parser.
\end{datadesc}


\begin{datadesc}{nofill}
Boolean flag which should be true when whitespace shoul...
...ects the operation of \code{handle_data()} and \code{save_end()}.
\end{datadesc}


\begin{funcdesc}{anchor_bgn}{href\, name\, type}
This method is called at the st...
... hyperlinks is available as the data attribute \code{anchorlist}.
\end{funcdesc}


\begin{funcdesc}{anchor_end}{}
This method is called at the end of an anchor reg...
...index into the
list of hyperlinks created by \code{anchor_bgn()}.
\end{funcdesc}


\begin{funcdesc}{handle_image}{source\, alt\optional{\, ismap\optional{\, align\...
...y passes the \code{alt} value to the \code{handle_data()}
method.
\end{funcdesc}


\begin{funcdesc}{save_bgn}{}
Begins saving character data in a buffer instead of...
...the \code{save_bgn()} / \code{save_end()} pair may not be
nested.
\end{funcdesc}


\begin{funcdesc}{save_end}{}
Ends buffering character data and returns all data ...
...all to \code{save_bgn()} will raise a
\code{TypeError} exception.
\end{funcdesc}