Extracting image src based on attribute with BeautifulSoup
I'm using BeautifulSoup to get a HTML page from IMDb, and I would like to
extract the poster image from the page. I've got the image based on one of
the attributes, but I don't know how to extract the data inside it.
Here's my code:
url = 'http://www.imdb.com/title/tt%s/' % (id)
soup = BeautifulSoup(urllib2.urlopen(url).read())
print "before FOR"
for src in soup.find(itemprop="image"):
print "inside FOR"
print(link.get('src'))
No comments:
Post a Comment