mardi 18 mars 2014

Python3 html.parser topic




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






Aucun commentaire:

Enregistrer un commentaire