Website hosting service by

 Back to Index

13.1.1 Example HTML Parser Application

As a basic example, below is a very basic HTML parser that uses the HTMLParser class to print out tags as they are encountered:

from HTMLParser import HTMLParser

class MyHTMLParser(HTMLParser):

    def handle_starttag(self, tag, attrs):
        print "Encountered the beginning of a %s tag" % tag

    def handle_endtag(self, tag):
        print "Encountered the end of a %s tag" % tag



2002-2004 Webhosting Service


Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to


Cheap domain registration : Buy domain name and enjoy comprehensive free services   Cheap domain registration : Buy domain name or register domain, including free domain hosting services