我在 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))
Run Code Online (Sandbox Code Playgroud)