简体   繁体   English

Python 中的 Selenium 未找到任何元素

[英]Selenium in Python not finding any elements

I have written numerous scripts to scrape websites.我编写了许多脚本来抓取网站。 I am looking to scrape games and odds from here: ('https://sportsbook.fanduel.com/navigation/nba')我希望从这里抓取游戏和赔率:('https://sportsbook.fanduel.com/navigation/nba')

I am not able to find any elements at all.我根本找不到任何元素。 I have looked for almost all of the div items, but tried root and it didn't work.我已经寻找了几乎所有的 div 项目,但尝试了 root 并且它没有工作。

the code:编码:

''' '''

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

options = webdriver.ChromeOptions()
options.add_argument("--enable-javascript")
driver = webdriver.Chrome('C:\\Location\\chromedriver',options=options)

driver.get('https://sportsbook.fanduel.com/navigation/nba')
time.sleep(20)
events = driver.find_element_by_xpath('//div[id="root"]')

''' '''

You have to prefix attributes with @.您必须在属性前面加上@。 So, the following should work所以,以下应该工作

events = driver.find_element_by_xpath('//div[@id="root"]')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM