Python3 html.parser

balaji marisetti balajimarisetti at gmail.com
Tue Mar 18 06:10:58 EDT 2014


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
-- 
:-)balaji
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140318/15fedeeb/attachment.html>


More information about the Python-list mailing list