【发布时间】:2020-06-08 10:48:19
【问题描述】:
我目前正在尝试遍历我拥有的大约 1000 行的数据框。对于每一行,都会调用一个网站。到目前为止,一切都很好。但是,当我尝试从网站中提取特定数据条目时,它会在 100 次循环后停止工作,有时在 300 次循环后停止工作。我当前的代码是:
for i in rows:
url = "https://www.boerse-stuttgart.de/en/products/investment-products/discount-certificates/stuttgart/{}".format(i)
r = requests.get(url)
soup = BeautifulSoup(r.text, "html.parser")
first_day = soup.find("dt", text="First exchange day").findNext('dd').string
rows 是我使用的数据框。我总是得到错误“'NoneType'对象没有属性'findNext'”。我的标签搜索有问题吗?我需要的数据条目在 dd 标记内,但现在有具体的名称,据我所知,我可以直接搜索。任何帮助是极大的赞赏。
【问题讨论】:
标签: python web-scraping beautifulsoup