【发布时间】:2020-03-28 16:06:14
【问题描述】:
我想从丹麦公司注册 (csv register) 下载给定公司的所有财务报告。一个例子可能是 Chr。汉森控股在以下链接:
具体来说,我想下载“Regnskaber”选项卡下的所有 PDF(=财务报告)。我以前没有使用 Python 进行网页抓取的经验。我尝试使用 BeautifulSoup,但鉴于我不存在的经验,我无法从响应中找到正确的搜索方式。
以下是我尝试过的,但没有打印任何数据(即它没有找到任何 pdf)。
from urllib.parse import urljoin
from bs4 import BeautifulSoup
web_page = "https://datacvr.virk.dk/data/visenhed?
enhedstype=virksomhed&id=28318677&soeg=chr%20hansen&type=undefined&language=da"
response = requests.get(web_page)
soup = BeautifulSoup(response.text)
soup.findAll('accordion-toggle')
for link in soup.select("a[href$='.pdf']"):
print(link['href'].split('/')[-1])
我们将不胜感激所有帮助和指导。
【问题讨论】:
标签: python web-scraping beautifulsoup