我正在编写一个基本的 python 脚本来解析来自 SEC.gov 网站的 RSS Feed 数据,但是当我运行脚本时它失败了。我哪里错了?
我使用的 Python 版本是 3.6.5,我尝试使用库 Atoma 和 feedparser,但我无法成功提取任何 SEC RSS 数据。老实说,可能是 rss 提要数据的格式不是有效格式(我检查了https://validator.w3.org/feed/并显示数据无效)。但是当我在 Google Chrome RSS 提要扩展中尝试相同的行时,它可以工作,所以我一定是做错了什么。有谁知道如何解决格式问题,还是我在 Python 中以错误的方式处理它?
import atoma, requests
feed_name = "SEC FEED"
url ='https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=0001616707&type=&dateb=&owner=exclude&start=0&count=100&output=atom'
response = requests.get(url)
feed = atoma.parse_rss_bytes(response.content)
for post in feed.items:
date = post.pub_date.strftime('(%Y/%m/%d)')
print("post date: " + date)
print("post title: " + post.title)
print("post link: " + post.link)