【发布时间】:2021-05-19 20:00:11
【问题描述】:
我正在尝试解析现场体育赛事结果网站的 html,但我的代码并未将所有跨度标签返回到该网站。我在检查下看到所有匹配项都是 ,但我的代码似乎无法从网站上找到除页脚或页眉之外的任何内容。也尝试过使用 div,但这些也不起作用。我是新手,有点迷路,这是我的代码,有人可以帮助我吗? 为了更清楚,我保留了 for 循环的第一部分。
#Creating the urls for the different dates
my_url='https://www.livescore.com/en/football/{}'.format(d1)
print(my_url)
today=date.today()-timedelta(days=i)
d1 = today.strftime("%Y-%m-%d/")
#Opening up the connection and grabbing the html
uClient=uReq(my_url)
page_html=uClient.read()
uClient.close()
#HTML parser
page_soup=soup(page_html,"html.parser")
spans=page_soup.findAll("span")
matches=page_soup.findAll("div", {"class":"LiveRow-w0tngo-0 styled__Root-sc-2sc0sh-0 styled__FootballRoot-sc-2sc0sh-4 eAwOMF"})
print(spans)
【问题讨论】:
标签: python web-scraping beautifulsoup html-parsing