使用 selenium 浏览网站。点击()不工作
Navigate website with selenium. Click() not working
编辑:另一场开始时改为湖人队比赛
我正在学习如何通过网络抓取投注赔率,我一整天都被这个问题所困扰。当我加载这个网站 Betway 时,它会转到 'Main Markets'(见下图)。我想转到其他选项卡,例如'Game Props' 或“上半场”。
url = "https://sports.betway.com/en/sports/evt/6183976"
driver = webdriver.Safari()
driver.get(url)
element = driver.find_element_by_xpath("/html/body/div/div/div[3]/div/div[1]/div/div[2]/div[4]/div/div[3]/div/div[2]/div/div[1]/div[2]/div/div/div[2]/div/div/div[4]/div/div")
element.click()
在其他网站上,我已经能够使用 find by elements 函数,然后使用 click() 函数来浏览页面。我不能让他们在这个网站上工作。我包含的底部图像是我检查时来自网站的代码。我真的很感激这里的一些建议!
To click()
选项卡上的文本为 Game Props 你必须诱导 for the element_to_be_clickable()
and you can use the following xpath based :
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[contains(., 'login or register')]"))).click()
注意:您必须添加以下导入:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
- 浏览器快照:
编辑:另一场开始时改为湖人队比赛
我正在学习如何通过网络抓取投注赔率,我一整天都被这个问题所困扰。当我加载这个网站 Betway 时,它会转到 'Main Markets'(见下图)。我想转到其他选项卡,例如'Game Props' 或“上半场”。
url = "https://sports.betway.com/en/sports/evt/6183976"
driver = webdriver.Safari()
driver.get(url)
element = driver.find_element_by_xpath("/html/body/div/div/div[3]/div/div[1]/div/div[2]/div[4]/div/div[3]/div/div[2]/div/div[1]/div[2]/div/div/div[2]/div/div/div[4]/div/div")
element.click()
在其他网站上,我已经能够使用 find by elements 函数,然后使用 click() 函数来浏览页面。我不能让他们在这个网站上工作。我包含的底部图像是我检查时来自网站的代码。我真的很感激这里的一些建议!
To click()
选项卡上的文本为 Game Props 你必须诱导 element_to_be_clickable()
and you can use the following xpath based
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[contains(., 'login or register')]"))).click()
注意:您必须添加以下导入:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
- 浏览器快照: