Python3 html.parser

B

balaji marisetti

Hi,

I'm trying to parse a pice of HTML code using `html.parser` in Python3.
I want to find out the offset of a particular end tag (let's say </p>) and
then stop processing
the remaining HTML code immediately. So I wrote something like this.

Code:
def handle_endtag(self, tag):
if tag == mytag:
#do something
self.reset()
[code]

I called `reset()` method at the end of  `handle_endtag()` method. Now the
problem is: when I call parser.feed("some html"), it's giving an
"AssertionError" exception. Isn't the `reset()` method
supposed to be called inside "handler" methods?

Thanks,
Balaji
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top