[issue25258] HtmlParser doesn't handle void element tags correctly
Ezio Melotti
report at bugs.python.org
Sat Oct 3 00:13:55 CEST 2015
Ezio Melotti added the comment:
> this inconsistent cannot be fixed from the inherited class as (handle_*
> calls are dispatched in the internal method of HTMLParser)
You can override handle_startendtag() like this:
>>> class MyHTMLParser(HTMLParser):
... def handle_starttag(self, tag, attrs):
... print('start', tag)
... def handle_endtag(self, tag):
... print('end', tag)
... def handle_startendtag(self, tag, attrs):
... self.handle_starttag(tag, attrs)
...
>>> parser = MyHTMLParser()
>>> parser.feed('<link rel="import"/><img src="som"/>')
start link
start img
(P.S. please don't quote the whole message in your reply)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25258>
_______________________________________
More information about the Python-bugs-list
mailing list