View Full Version : Get value of "<img src="x..." for cover


miwie
11-20-2010, 11:19 AM
A newspaper holds thumbnails for every edition on a gallery page.

How can I fetch the value of an "<img src="..."> (inside a specific "<div class="XXX">") in "get_cover_url(self)" to get this image file as cover image.

Michael

Starson17
11-20-2010, 12:24 PM
A newspaper holds thumbnails for every edition on a gallery page.

How can I fetch the value of an "<img src="..."> (inside a specific "<div class="XXX">") in "get_cover_url(self)" to get this image file as cover image.

Michael


def get_cover_url(self):
cover_url = None
index = 'http://some.where.com/some-page'
soup = self.index_to_soup(index)
link_item = soup.find('div',attrs={'class':'XXX'})
if link_item:
cover_url = link_item.img['src']
return cover_url

miwie
11-20-2010, 12:47 PM
Thanks!

Works the way I want.

Starson17
11-22-2010, 12:50 PM
Thanks!

Works the way I want.

You're welcome.