Python 美化组在开发工具中找不到元素

Python 美化组在开发工具中找不到元素,python,html,beautifulsoup,Python,Html,Beautifulsoup,我正试图从中提取一些数据,但似乎我找不到任何东西。。。我尝试存储soup.select或soup.find\的所有变量都为空 当我只是打印“汤”时,它不包括我试图找到的这些类,所以我想知道我是否遗漏了一些基本的东西 from bs4 import BeautifulSoup import requests url = 'https://www.oddsportal.com/rugby-union/france/pro-d2/results/' response = requests.get(u

我正试图从中提取一些数据,但似乎我找不到任何东西。。。我尝试存储soup.select或soup.find\的所有变量都为空

当我只是打印“汤”时,它不包括我试图找到的这些类,所以我想知道我是否遗漏了一些基本的东西

from bs4 import BeautifulSoup
import requests

url = 'https://www.oddsportal.com/rugby-union/france/pro-d2/results/'
response = requests.get(url)
html = response.content

soup = BeautifulSoup(html, 'html.parser')
seasons = soup.find_all('ul', {'class': 'main-filter'}) # list of links for all seasons

# other things I've tried to find:

#total = soup.find_all('div', {'id': 'tournamentTable'})
#total = soup.select('#tournamentTable')
#league = soup.select('tr', {'class': 'dark center'})
#league = soup.select('body a')
#date = soup.find_all('tr', {'class': 'center nob-border'})
#match = soup.find_all('span[class*="deactivate"]')

#<a class="bfl sicona s8" href="/rugby-union/">Rugby Union</a>

print(seasons)
#print(total)
#print(league)
#print(date)
#print(match)

这仅仅是因为数据是由javascript加载的。考虑使用硒

from bs4 import BeautifulSoup
from selenium import webdriver

url = 'https://www.oddsportal.com/rugby-union/france/pro-d2/results/'

DRIVER_PATH="Your selenium chrome driver path"
driver = webdriver.Chrome(executable_path=DRIVER_PATH)
driver.get(url)

soup = BeautifulSoup(driver.page_source, 'html.parser')
driver.quit()
seasons = soup.find_all('ul', {'class': 'main-filter'}) # list of links for all seasons
print(seasons)

这是一个js呈现的页面。您需要使用selenium来实现自动化。您不需要手动安装chromedriver,然后定义可执行路径的路径。您可以改用webdriver\u管理模块

from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager

chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options)

url = 'https://www.oddsportal.com/rugby-union/france/pro-d2/results/'
driver.get(url)
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
seasons = soup.find_all('ul', {'class': 'main-filter'}) # list of links for all 
print(seasons)

谢谢我收到了这个错误,但我已经安装了selenium…``从webdriver\u manager.chrome导入ChromeDriverManager modulenofounderror:没有名为“webdriver\u manager”的模块``编辑:我想我现在可以使用它了``从webdriver\u manager.chrome导入ChromeDriverManager.chrome```