【发布时间】:2022-12-19 19:18:22
【问题描述】:
我正在尝试从 NBA.com 进行一些网络抓取,但我正在查看的表格似乎被隐藏了。如何在请求中显示隐藏的 HTML 内容。我正在尝试出于学习目的这样做。
导入请求 从 bs4 导入 BeautifulSoup
url = 'https://www.nba.com/stats/player/203076/boxscores-traditional?Season=2022-23'
data = requests.get(url)
info = "Davis"
with open ('{}.html'.format(info), 'w+', encoding="utf-8") as f:
f.write(data.text)
# We read the file we created
with open ("{}.html".format(info), encoding="utf-8") as f:
page = f.read()
# We use the BeautifulSoup library
soup = BeautifulSoup(page, 'html.parser')
stats = soup.find_all('table', class_='Crom_table__p1iZz')
我希望看到表类 Crom_table__p1iZz 及其 tr 内容
【问题讨论】:
标签: python html web-scraping beautifulsoup python-requests