首页 > 解决方案 > 使用 selenium 抓取博彩网站的网页。不完整的事件列表

问题描述

我编写了一个程序来从“Eurobet.it”网站获得一些赔率,使用 selenium 打开包含“ChanceMix”的页面。似乎它有效,但是当游戏发生在多个日期时,我得到的列表是不完整的。它仅包含第一个/第二个日期的日期,但不包含下一个日期。我尝试了各种解决方案,但没有结果。有人能帮我吗?

这是我的代码:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import ui
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By


link = 'https://www.eurobet.it/it/scommesse/#!/calcio/eu-champions-league/'
driver = webdriver.Chrome()
driver.get(link)

# Find the "ChanceMix" button by xpath and store it as a webdriver object
element = driver.find_element_by_xpath("//a[contains(text(), 'ChanceMix')]")

# Click on the "ChanceMix" button to open the relevant page
element.click()

# Find the list of games
Games = ui.WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div.box-sport")))

# Print the list of games
for x in range(0,len(Games)): print(Games[x].text)

标签: python-3.xseleniumweb-scraping

解决方案


推荐阅读