Message252168
> 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) |
|
Date |
User |
Action |
Args |
2015-10-02 22:13:55 | ezio.melotti | set | recipients:
+ ezio.melotti, martin.panter, josh.r, xiang.zhang, Chenyun Yang |
2015-10-02 22:13:55 | ezio.melotti | set | messageid: <1443824035.29.0.188037367081.issue25258@psf.upfronthosting.co.za> |
2015-10-02 22:13:55 | ezio.melotti | link | issue25258 messages |
2015-10-02 22:13:55 | ezio.melotti | create | |
|