繁体   English   中英

Selenium webdriver 未找到 xpath 元素

[英]Selenium webdriver not finding xpath elements

我正在尝试从此网站链接中获取所有餐厅位置,但每次我这样做时,它都会返回一个空字符串列表。 我能做些什么得到我需要的清单?

driver = Chrome(path_to_chrome_driver)
driver.get('https://www.marriott.com/hotels/fact-sheet/travel/CZLMC-Constantine-Marriott-Hotel')
restaurants = driver.find_elements_by_xpath('//h3[@class="l-margin-top-none"]')
restaurants = [item.text for item in restaurants]
print(restaurants)

尝试获取以下餐厅:

restaurants = [item.get_property('textContent') for item in restaurants]

暂无
暂无

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

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