我正在嘗試制作一個使用 Selenium 提取一些資料的 Python 程式,首先我必須關閉兩個警報,然后單擊“顯示所有匹配項”按鈕,最后我需要單擊每個“統計資訊”按鈕(有多個,它們都具有相同的類名)以從該表中提取特定行。

我需要為每個游戲提取以藍色突出顯示的 4 個值

我已經完成了前兩個步驟,但現在我被困在最后一步,我必須點擊每個“統計”按鈕,從每個表中提取 4 個值,然后關閉視窗并移動到下一個游戲。
這是我的代碼
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
s=Service("C:/Users/dhias/OneDrive/Bureau/stgg/chromedriver.exe")
driver=webdriver.Chrome(service=s)
driver.get("https://www.soccerstats.com/matches.asp?matchday=1#")
driver.maximize_window()
time.sleep(1)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[mode='primary']"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID,"steady-floating-button"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Show all matches']"))).click()
我試著點擊每個具有相同類名的“統計”按鈕,但它沒有用
for element in driver.find_elements(By.XPATH,"//a[@class='myButton' and text()='stats']"):
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH,"//a[@class='myButton' and text()='stats']"))).click()
網站鏈接:
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/464792.html
標籤:Python python-3.x 硒 硒网络驱动程序 网页抓取
