html.parser.HTMLParser.unknown_decl()

HTMLParser.unknown_decl(data) This method is called when an unrecognized declaration is read by the parser. The data parameter will be the entire contents of the declaration inside the <![...]> markup. It is sometimes useful to be overridden by a derived class. The base class implementation does nothing.

html.parser.HTMLParser.reset()

HTMLParser.reset() Reset the instance. Loses all unprocessed data. This is called implicitly at instantiation time.

html.parser.HTMLParser.handle_starttag()

HTMLParser.handle_starttag(tag, attrs) This method is called to handle the start of a tag (e.g. <div id="main">). The tag argument is the name of the tag converted to lower case. The attrs argument is a list of (name, value) pairs containing the attributes found inside the tag’s <> brackets. The name will be translated to lower case, and quotes in the value have been removed, and character and entity references have been replaced. For instance, for the tag <A HREF="https://www

html.parser.HTMLParser.handle_startendtag()

HTMLParser.handle_startendtag(tag, attrs) Similar to handle_starttag(), but called when the parser encounters an XHTML-style empty tag (<img ... />). This method may be overridden by subclasses which require this particular lexical information; the default implementation simply calls handle_starttag() and handle_endtag().

html.parser.HTMLParser.handle_pi()

HTMLParser.handle_pi(data) Method called when a processing instruction is encountered. The data parameter will contain the entire processing instruction. For example, for the processing instruction <?proc color='red'>, this method would be called as handle_pi("proc color='red'"). It is intended to be overridden by a derived class; the base class implementation does nothing. Note The HTMLParser class uses the SGML syntactic rules for processing instructions. An XHTML processing instruc

html.parser.HTMLParser.handle_entityref()

HTMLParser.handle_entityref(name) This method is called to process a named character reference of the form &name; (e.g. &gt;), where name is a general entity reference (e.g. 'gt'). This method is never called if convert_charrefs is True.

html.parser.HTMLParser.handle_endtag()

HTMLParser.handle_endtag(tag) This method is called to handle the end tag of an element (e.g. </div>). The tag argument is the name of the tag converted to lower case.

html.parser.HTMLParser.handle_decl()

HTMLParser.handle_decl(decl) This method is called to handle an HTML doctype declaration (e.g. <!DOCTYPE html>). The decl parameter will be the entire contents of the declaration inside the <!...> markup (e.g. 'DOCTYPE html').

html.parser.HTMLParser.handle_data()

HTMLParser.handle_data(data) This method is called to process arbitrary data (e.g. text nodes and the content of <script>...</script> and <style>...</style>).

html.parser.HTMLParser.handle_comment()

HTMLParser.handle_comment(data) This method is called when a comment is encountered (e.g. <!--comment-->). For example, the comment <!-- comment --> will cause this method to be called with the argument ' comment '. The content of Internet Explorer conditional comments (condcoms) will also be sent to this method, so, for <!--[if IE 9]>IE9-specific content<![endif]-->, this method will receive '[if IE 9]>IE9-specific content<![endif]'.