Feedparser-basics如何

Jam*_*hai 5 python rss feedparser

我是Feedstarser的新手,经过长时间的休息后回到了Python,所以非常感谢任何帮助.我已经尝试了非常好的文档,但我仍然有点滞后.

我如何让Feedparser获取rss feed并从中获取前10个项目的标题和描述并单独标记每个项目,以便它们可以插入到其他代码的任何位置?即.我可以使用第一和第二项的标题和其他人的描述?

希望有道理!任何帮助非常感谢

Kur*_*Kee 6

import feedparser
f = feedparser.parse('http://domain/feed')
# f contains a dictionary key 'entries'
# entries is a list of dictionaries with 'title' and 'content' keys
for e in f['entries']:
    print e.get('title', '')
    print e.get('summary', '')
Run Code Online (Sandbox Code Playgroud)

希望有所帮助.