解析有问题,目标包含连字符
Trouble with parsing, target contains a hyphen
我正在尝试从 RSS 提要中获取一些信息,更具体地说是 "filing-type" 部分中包含的数据。但是该部分包含连字符,因此当我 运行 代码时:
import feedparser
BEGIN_URL = "https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK="
FINISH_URL = "&type=&dateb=&owner=include&start=0&count=40&output=atom"
def check_sec_rss(ticker):
TARGET_URL = BEGIN_URL+ticker+FINISH_URL
feed = feedparser.parse(TARGET_URL)
for post in feed.entries:
print(post.filing-type)
check_sec_rss("AAPL")
我收到一个错误:
Traceback (most recent call last):
File "D:/icsusV0.1/test3.py", line 10, in <module>
check_sec_rss("APDN")
File "D:/icsusV0.1/test3.py", line 8, in check_sec_rss
print(post.filing-type)
File "C:\Users\domin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\feedparser.py", line 400, in __getattr__
raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'filing'
有人能给我指出正确的方向吗?
通过反复试验来管理它...
print(post['filing-type'])
我正在尝试从 RSS 提要中获取一些信息,更具体地说是 "filing-type" 部分中包含的数据。但是该部分包含连字符,因此当我 运行 代码时:
import feedparser
BEGIN_URL = "https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK="
FINISH_URL = "&type=&dateb=&owner=include&start=0&count=40&output=atom"
def check_sec_rss(ticker):
TARGET_URL = BEGIN_URL+ticker+FINISH_URL
feed = feedparser.parse(TARGET_URL)
for post in feed.entries:
print(post.filing-type)
check_sec_rss("AAPL")
我收到一个错误:
Traceback (most recent call last):
File "D:/icsusV0.1/test3.py", line 10, in <module>
check_sec_rss("APDN")
File "D:/icsusV0.1/test3.py", line 8, in check_sec_rss
print(post.filing-type)
File "C:\Users\domin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\feedparser.py", line 400, in __getattr__
raise AttributeError("object has no attribute '%s'" % key)
AttributeError: object has no attribute 'filing'
有人能给我指出正确的方向吗?
通过反复试验来管理它...
print(post['filing-type'])