I am using this feed http://feeds.bbci.co.uk/news/rss.xml and want to get all media:thumbnail entries. Ie all images
import feedparser
d = feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml')
e = d['entries'][0]
print e.media_thumbnail ## this returns ''
The entry has this in the rss:
media:thumbnail width="66" height="49" url="http://news.bbcimg.co.uk/media/images/50560000/jpg/_50560468_50557389.jpg"
media:thumbnail width="144" height="81" url="http://news.bbcimg.co.uk/media/images/50581000/jpg/_50581208_010904244-1.jpg"
So, the info is there, but how can I get it?
(I am using the latest feedparser version feedparser. version -> '4.2-pre-294-svn')
Using the latest SVN r354 I got this working:
>>> e = d['entries'][0]
>>> print e["media_thumbnail"][0]["url"]
http://news.bbcimg.co.uk/media/images/50560000/jpg/_50560468_50557389.jpg
This works just as well especially if you want the picture for each article in the feed:
d = feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml')
for entry in d.entries:
print(entry.media_thumbnail)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.