【发布时间】:2020-01-15 23:55:19
【问题描述】:
我觉得我错过了一些非常基本的东西,但我被困住了。我只是想用 Beautiful Soup 返回一张桌子,但由于某种原因,它没有按 ID 抓取带有线分数的桌子。我可以通过他们在这个页面上的 ID 来定位其他 div 和表格,但由于某种原因,这个没有返回任何东西。知道我缺少什么吗?
from urllib.request import urlopen
from bs4 import BeautifulSoup
import ssl
url = 'https://www.sports-reference.com/cbb/boxscores/2020-01-14-19-clemson.html'
html = urlopen(url)
soup = BeautifulSoup(html.read(), 'html.parser')
ls = soup.find_all('table', {"id": "line-score"})
【问题讨论】:
-
看来问题出在调用那个id
-
我试过了,我自己也搞糊涂了
-
我建议使用 requests 包,这对我有帮助
标签: python web-scraping beautifulsoup