使用 BeautifulSoup 或 Selenium 抓取网站时找不到数据

萨姆辛

我正在尝试抓取一个站点以获取最新情况说明书的链接。我尝试过使用 Selenium 和 BeautifulSoup,但是每次我都无法使用这些工具找到链接。例如,当使用 Soup 检查输出时,我无法从零件中得到任何信息。有什么建议?

链接到站点抓取的站点

使用硒:

#BIOG
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.headless = True

driver = webdriver.Chrome(options=options)
driver.get('https://www.biotechgt.com/performance/monthly-factsheets')
html = driver.page_source

driver.find_elements(By.XPATH, '/html/body/div/main/section/div/div/div/div/div[2]/div/div[1]/div[2]/div/table/tbody[1]/tr[2]/td/a')
安德烈·凯斯利

要从页面获取所有下载链接,您可以使用下一个示例:

import requests
from bs4 import BeautifulSoup

url = "https://www.biotechgt.com/performance/monthly-factsheets"

soup = BeautifulSoup(
    requests.get(url, cookies={"dp-disclaimer": "APPROVED"}).content,
    "html.parser",
)

for a in soup.select("a.gtm-downloads:has(.btn-download)"):
    print(a["href"])

印刷:

https://www.biotechgt.com/download_file/force/191/209
https://www.biotechgt.com/download_file/force/187/209
https://www.biotechgt.com/download_file/force/185/209
https://www.biotechgt.com/download_file/force/184/209

...

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用BeautifulSoup和Selenium抓取特定的html标签

如何使用Python Selenium BeautifulSoup抓取表格html格式的数据?

如何在python中使用Selenium和Beautifulsoup解析网站?

如何在python中使用Selenium和Beautifulsoup解析网站?

使用BeautifulSoup抓取网站时阅读页码

在Python中浏览Selenium并使用BeautifulSoup进行抓取

使用BeautifulSoup抓取网站时显示符号

使用python selenium / Beautifulsoup从多个页面提取数据

使用Selenium和BeautifulSoup输入内容来抓取网站?

使用Selenium在Python上进行网络抓取时找不到div类

当我尝试使用BeautifulSoup从网站抓取时缺少文本

使用Selenium和BeautifulSoup搜寻网站

使用BeautifulSoup抓取特定网站

使用 BeautifulSoup 和 Selenium 抓取一个网站的多个网页的内容

使用 Python、Selenium 和 BeautifulSoup 来抓取标签的内容?

使用来自 AJAX 网站的 selenium 和 beautifulsoup 在 python 中抓取图像

使用 Selenium 和 BeautifulSoup 抓取饥饿游戏的用户评分

使用 BeautifulSoup 从网站抓取数据的问题

使用 BeautifulSoup 抓取数据

使用 BeautifulSoup 和 Selenium 的网页抓取网站不会检测网页中的表格元素

使用 python 抓取网站 - BeautifulSoup

使用 beautifulsoup 和 selenium 抓取多页网站返回空字符串列表

无法使用 Selenium 和 BeautifulSoup 抓取文本

不使用beautifulsoup抓取网站数据

使用 Selenium 和 BeautifulSoup 进行网页抓取返回空列表

在 python 网页抓取中使用 Selenium 对 BeautifulSoup 进行分页

使用 BeautifulSoup 进行网页抓取,在 html 中找不到表格

使用 BeautifulSoup 和 Selenium 抓取数据

使用 Selenium 和 BeautifulSoup 进行 Zillow 网页抓取