0
Stackoverflow RSS源中的每个作业项都具有某些标签,其中包含关键字“category”。使用Python中的Feedparser解析Stackoverflow相同名称元素的RSS作业源
展望基本上是这样的:
<category>scala</category>
<category>hadoop</category>
<category>apache-spark</category>
<category>hive</category>
<category>json</category>
我想用Feedparser,把所有的标签放入一个列表。相反,我总是得到第一个元素。 Feedparser文档提到entries[i].content,但我不确定这是否正确,或者在这种情况下如何使用它。
这里是我的代码:
import feedparser
rss_url = "https://stackoverflow.com/jobs/feed"
feed = feedparser.parse(rss_url)
items = feed["items"]
for item in items:
title = item["title"]
try:
tags = []
tags.append(item["category"])
print(title + " " + str(tags))
except:
print("Failed")
解决了!谢谢。 – Felix