【发布时间】:2020-03-08 12:37:36
【问题描述】:
您好,我目前正在尝试使用 beautifulsoup 抓取此 https://www.sec.gov/ix?doc=/Archives/edgar/data/1090727/000109072720000003/form8-kq42019earningsr.htmSEC 链接以获取包含“UPS”的链接
pressting = soup3.find_all("a", string="UPS")
linkkm = pressting.get('href')
print(linkkm)
但是当我这样做时,我得到了这个错误:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\SEC.py", line 55, in <module>
print('Price: ' + str(edgar()))
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\SEC.py", line 46, in edgar
linkkm = pressting.get('href')
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\element.py", line 2081, in __getattr__
"ResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?" % key
AttributeError: ResultSet object has no attribute 'get'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
我的预期结果是提取 href,然后打印该 href。任何帮助将不胜感激。
【问题讨论】:
-
不确定您希望得到哪个
href? -
@αԋɱҽԃαмєяιcαη 我正在尝试获取此行的 href:99.1 2020 年 1 月 30 日新闻稿“UPS RELEASES 4Q 2019 EARNINGS”。这是sec.gov/Archives/edgar/data/1090727/000109072720000003/…
-
然后检查下面的答案。
标签: python web-scraping beautifulsoup