Python 从FlashScore.ro live中获取信息
我正试图从live选项卡上从该网站上获取信息。我想在每次有事情发生时收到一封电子邮件 但我的问题是刮 到目前为止,我拥有的代码没有返回任何值。我现在想知道主队的名字 我有点不熟悉用python刮东西Python 从FlashScore.ro live中获取信息,python,web-scraping,beautifulsoup,python-requests,Python,Web Scraping,Beautifulsoup,Python Requests,我正试图从live选项卡上从该网站上获取信息。我想在每次有事情发生时收到一封电子邮件 但我的问题是刮 到目前为止,我拥有的代码没有返回任何值。我现在想知道主队的名字 我有点不熟悉用python刮东西 import requests from bs4 import BeautifulSoup URL = 'https://www.flashscore.ro/baschet/' headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6
import requests
from bs4 import BeautifulSoup
URL = 'https://www.flashscore.ro/baschet/'
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36'}
def find_price():
page = requests.get(URL, headers = headers)
soup = BeautifulSoup(page.content, 'html.parser')
home_team = soup.html.find('div', {'class': 'event__participant event__participant--home'})
return home_team
print(find_price())
该网站使用JavaScript,但
请求
不支持它。因此,我们可以使用它作为一种替代方法来刮取页面
安装时使用:pip Install selenium
从下载正确的ChromeDriver
输出:
Lyon-Villeurbanne
Fortitudo Bologna
Virtus Roma
Treviso
Trieste
Trento
Unicaja
Gran Canaria
Galatasaray
Horizont Minsk 2 F
...And on
Lyon-Villeurbanne
Fortitudo Bologna
Virtus Roma
Treviso
Trieste
Trento
Unicaja
Gran Canaria
Galatasaray
Horizont Minsk 2 F
...And on