|
|
#1 |
|
Connoisseur
![]() Posts: 76
Karma: 12
Join Date: Nov 2010
Device: Android, PB Pro 602
|
Get value of "<img src="x..." for cover
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 Last edited by miwie; 11-20-2010 at 11:21 AM. |
|
|
|
|
|
#2 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
Code:
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
|
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Connoisseur
![]() Posts: 76
Karma: 12
Join Date: Nov 2010
Device: Android, PB Pro 602
|
Thanks!
Works the way I want. |
|
|
|
|
|
#4 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| element "img" not allowed in this context | graniton | Calibre | 5 | 05-15-2012 12:39 AM |
| "Settings," then "311" - Int'l Kindle searches for wireless providers in the area | Dr. Drib | Amazon Kindle | 2 | 08-28-2011 11:27 AM |
| Yep. It's official. Sony Reader has "ruined" books for me. A final "review." | WilliamG | Sony Reader | 48 | 01-14-2011 04:49 AM |
| Woher bekomme ich "Infinite Jest" oder "Unendlicher Spaß" von David Foster Wallace? | bitschnau | Erste Hilfe | 3 | 11-01-2010 02:22 PM |
| My DIY cover for the Kobo - the "KoBook" (or "BooKobo") | Beorn | Kobo Reader | 4 | 07-12-2010 08:06 PM |