I'm trying to extract an image source url from a HTML img tag.
if html data is like below:
<div> My profile <img width='300' height='300' src='http://domain.com/profile.jpg'> </div>
or
<div> My profile <img width="300" height="300" src="http://domain.com/profile.jpg"> </div>
how's the regex in python?
I had tried below:
i = re.compile('(?P<src>src=[["[^"]+"][\'[^\']+\']])')
i.search(htmldata)
but I got an error
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'