3
Contributors
2
Replies
20
Views
2 Years
Discussion Span
Last Post by Gribouillis
0
from bs4 import BeautifulSoup
import urllib2

html = '''
<img src="smiley.gif" alt="Smiley face" height="42" width="42">'''

soup = BeautifulSoup(html)
images = soup.find('img')
print(images['src']) #smiley.gif
0

This seems to be working

>>> url = urllib2.urlopen('http://www.python.org')
>>> soup = BeautifulSoup(url)
>>> srcs = [img['src'] for img in soup.find_all('img')]
>>> srcs
['/static/img/python-logo.png']
>>>

Edited by Gribouillis

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.