【发布时间】:2019-09-20 00:23:48
【问题描述】:
我在 Python 上构建了一个简单的 RSS 阅读器,但它无法正常工作。 另外,我想获取每个帖子的特色图片源链接,但我没有找到方法。
它向我显示错误:回溯(最近一次调用最后一次):文件 “RSS_reader.py”,第 7 行,在 feed_title = feed['feed']['title']
如果还有其他一些可以正常工作的 RSS 提要。所以我不明白为什么有些 RSS 提要有效,而另一些则无效
所以我想了解为什么代码不起作用以及如何获取帖子的特色图片源链接 我附上了代码,是用 Python 3.7 编写的
import feedparser
import webbrowser
feed = feedparser.parse("https://finance.yahoo.com/rss/")
feed_title = feed['feed']['title']
feed_entries = feed.entries
for entry in feed.entries:
article_title = entry.title
article_link = entry.link
article_published_at = entry.published # Unicode string
article_published_at_parsed = entry.published_parsed # Time object
article_author = entry.author
content = entry.summary
article_tags = entry.tags
print ("{}[{}]".format(article_title, article_link))
print ("Published at {}".format(article_published_at))
print ("Published by {}".format(article_author))
print("Content {}".format(content))
print("catagory{}".format(article_tags))
【问题讨论】:
标签: python rss python-3.7 feedparser