Question: Implement a class named HeadingParser that can be used to parse an HTML document, and retrieve and print all the headings in the document. You
Implement a class named HeadingParser
that
can be used to parse an HTML document, and retrieve and print all the
headings in the document. You should implement your class as a subclass
of HTMLParser, defined in Standard Library module html.parser. When fed a string
containing HTML code, your class should print the headings, one per line and in
the order in which they appear in the document. Each heading should be
indented as follows: an h1 heading should have indentation 0, and h2
heading should have indentation 1, etc. Test your implementation using
w3c.html.
>>> infile = open('w3c.html')
>>> content = infile.read()
>>>
infile.close()
>>> hp = HeadingParser()
>>>
hp.feed(content)
W3C
Mission
Principles
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
