【发布时间】:2020-07-06 23:38:26
【问题描述】:
我是 python 新手,我使用 BeautifulSoup 从以下位置抓取数据:https://www.espn.com/mma/fightcenter
我可以在第一个战斗列表中执行所有我想要的操作,因为它默认展开。但是,我在后面的列表中遇到了问题,因为我想要的数据隐藏在“div”树下。
有没有办法在制作“汤”时在整个网页上展开所有这些树?
以下是我正在使用的当前代码行:
headers = requests.utils.default_headers()
headers.update({ 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101
Firefox/52.0'})
espnurl = 'https://www.espn.com/mma/fightcenter'
req = requests.get(espnurl, headers)
soup = BeautifulSoup(req.content, 'html5lib')
提前致谢!
【问题讨论】:
-
嗨@burns 你找到问题的答案了吗?我也遇到了同样的问题,希望得到帮助。
标签: python web-scraping beautifulsoup