Manas Paldhe
Manas Paldhe

Reputation: 776

Parsing RSS in Python

I am trying to parse rss feed using python.

The rss feed has the format:

 <rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
      <channel>
                <title>Yahoo! News - Latest News & Headlines</title>
                <link>http://news.yahoo.com/</link>
                <description>...</description>
                <language>en-US</language>
                <copyright>Copyright (c) 2013 Yahoo! Inc. All rights reserved</copyright>
                <pubDate>Thu, 30 May 2013 21:14:41 -0400</pubDate>
                <ttl>5</ttl>
                <image>...</image>
                <item>...</item>
                <item>...</item>
                <item>...</item>
      </channel>
 </rss>

I need to extract some details of the <items>.

Using print feed['channel']['title'] etc I can get details of those blocks occurring only once. How do I extract details of the items? feed['channel']entries[0] or feed['channel']['items[0]] etc do not seem to work.

Upvotes: 2

Views: 3772

Answers (1)

Manas Paldhe
Manas Paldhe

Reputation: 776

feed.entries[doc_iter]['title'] 

Seems to work. The doc_iter mentions the ith item.

Upvotes: 1

Related Questions