internet data handling and encoding handle_endtag(tagthis handler is called whenever end tags are encountered tag is the name of the tag converted to lowercase for exampleif the end tag is ''tag is the string 'bodyh handle_entityref(namethis handler is called to handle entity references such as '&name;name is string containing the name of the reference for exampleif parsing '&lt;'name will be set to 'lth handle_pi(datathis handler is called to handle processing instructions such as '<?processing instruction>data is string containing the text of the processing instruction not including the leading 'when called on xhtml-style instructions of the form ''the last '?will be included in data handle_startendtag(tagattrsthis handler processes xhtml-style empty tags such as '<tag name="value/>tag is string containing the name of the tag attrs contains attribute information and is list of tuples of the form (namevaluewhere name is the attribute name converted to lowercase and value is the attribute value when extracting valuesquotes and character entities are replaced for exampleif parsing '< href="[('href','implementation of this method simply calls handle_starttag(and handle_endtag( handle_starttag(tagattrsthis handler processes start tags such as 'tag and attrs have the same meaning as described for handle_startendtag( reset(resets the parserdiscarding any unprocessed data the following exception is providedhtmlparsererror exception raised as result of parsing errors the exception has three attributes the msg attribute contains message describing the errorthe lineno attribute is the line number where the parsing error occurredand the offset attribute is the character offset into the line example the following example fetches an html document using the urllib package and prints all links that have been specified with 'declarationsprintlinks py tryfrom htmlparser import htmlparser from urllib import urlopen except importerrorfrom html parser import htmlparser lib fl ff