[issue29276] HTMLParser in Python 2.7 doesn't recognize image tags wrapped up in link tags

Brendan Donegan report at bugs.python.org
Sat Jan 14 12:58:10 EST 2017


Brendan Donegan added the comment:

I even get the correct behaviour in 2.7.12:
Python 2.7.12+ (default, Sep 17 2016, 12:08:02) 
[GCC 6.2.0 20160914] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from HTMLParser import HTMLParser
>>> class MyHTMLParser(HTMLParser):
...     def handle_starttag(self, tag, attrs):
...         print("Encountered a start tag: %s" % tag)
... 
>>> parser = MyHTMLParser()
>>> parser.feed('<a href="http://somesite.com/large_image.jpg"><img src="http://somesite.com/small_image.jpg" width="800px" /></a>')
Encountered a start tag: a
Encountered a start tag: img

Ari, can you provide more info about the exact version and platform you are using?

----------
nosy: +brendan-donegan

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29276>
_______________________________________


More information about the Python-bugs-list mailing list