Search code examples
pythonfeedfeedparser

How to get image from this BBC feed using Python and Universal Feed Parser


I am using this feed http://feeds.bbci.co.uk/news/rss.xml and want to get all media:thumbnail entries. I.e. 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')


Solution

  • 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