2

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.

3
  • I assume you are using some sort of XML or RSS parsing library for this? Commented May 31, 2013 at 4:16
  • I am using the feedparser library Commented May 31, 2013 at 4:18
  • Is this what you need? pythonhosted.org/feedparser/… "The items are available in d.entries, which is a list." Commented May 31, 2013 at 4:29

1 Answer 1

1
feed.entries[doc_iter]['title'] 

Seems to work. The doc_iter mentions the ith item.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.