用Python解析RSS

问题描述 投票:2回答:1

我试图使用python解析rss feed。

rss feed的格式为:

 <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>

我需要提取一些<items>的细节。

使用print feed['channel']['title']等我可以获得仅出现一次的那些块的细节。如何提取项目的详细信息? feed['channel']entries[0]feed['channel']['items[0]]等似乎不起作用。

python rss feedparser
1个回答
1
投票
feed.entries[doc_iter]['title'] 

似乎工作。 doc_iter提到了第i项。

© www.soinside.com 2019 - 2024. All rights reserved.