我正在使用一些固定的Feed制作一个小的webapp(固定为,你不能添加Feedly或Google Reader中的Feed)
我试过这个,没有运气
RSS_URLS = [
'http://feeds.feedburner.com/RockPaperShotgun',
'http://www.gameinformer.com/b/MainFeed.aspx?Tags=preview',
]
feed = feedparser.parse(RSS_URLS)
for post in feed.entries:
print post.title
而这一点,没有运气
RSS_URLS = [
'http://feeds.feedburner.com/RockPaperShotgun',
'http://www.gameinformer.com/b/MainFeed.aspx?Tags=preview',
]
feed = []
for url in RSS_URLS:
feed.append(feedparser.parse(url))
for post in feed.entries:
print post.title
答案 0 :(得分:2)
您的第二种方法是可以的,但是当您将Feed附加到列表中时, 您还将获得条目提要列表,因此:
RSS_URLS = [
'http://feeds.feedburner.com/RockPaperShotgun',
'http://www.gameinformer.com/b/MainFeed.aspx?Tags=preview',
]
feeds = []
for url in RSS_URLS:
feeds.append(feedparser.parse(url))
for feed in feeds:
for post in feed.entries:
print post.title
或制作所有帖子的详细列表,extend
列表,其中包含每个网址的新条目列表:
posts = []
for url in RSS_URLS:
posts.extend(feedparser.parse(url).entries)
for post in posts:
print post.title