【发布时间】:2020-10-10 04:33:02
【问题描述】:
我无法在以下代码中找到 div 类。
网址如下:
https://www.oddsportal.com/basketball/usa/nba/los-angeles-lakers-miami-heat-IqLamQfL/#over-under;1
我的代码如下:
html_doc = urllib.request.urlopen(new_url).read()
odds_soup = BeautifulSoup(html_doc, 'html.parser')
table_header = odds_soup.find_all('div', {'id' : "odds-data-table", 'class' : 'bt-2'})
list = []
table_containers = []
for tag in table_header:
table_containers += tag.find_all('div', {'class' : 'table-container'})
但是代码只返回一个空的 table_containers 列表。我不知道为什么,非常感谢一些帮助。
查看网站后,如下所示:
【问题讨论】:
-
尝试将解析器更改为
html5lib执行pip install html5lib,我认为还建议使用requests而不是urllib
标签: python python-3.x selenium web-scraping beautifulsoup