【发布时间】:2021-04-26 08:44:57
【问题描述】:
我正在尝试收集 2020 年 12 月的 Steams 硬件和软件调查(页面底部的表格)。通过单击其中一个父项(例如“OS 版本”),可以展开该表。我的目标是访问这些父母中的表。
https://store.steampowered.com/hwsurvey#main_stats
到目前为止,我已尝试使用 requests 和 BeautifulSoup(使用不同的解析器)检索此信息,但 Beautifulsoup 始终返回 TypeError: 'NoneType' object is not callable。在搜索 API 失败后,我尝试将 Selenium 与 pd.read_html() 结合使用。使用这种方法,我至少可以访问表格上方图表中的 y 标签,但不能访问下面所需的表格:
import pandas as pd
from selenium import webdriver
url = "https://store.steampowered.com/hwsurvey#main_stats"
opt = webdriver.FirefoxOptions()
opt.add_argument('-headless')
driver = webdriver.Firefox(options=opt)
driver.get(url)
pd.read_html(driver.page_source)
我很感激任何可以帮助我克服这个问题的建议。
【问题讨论】:
标签: python pandas selenium-webdriver beautifulsoup