我想提取一本书中的星星数亚马逊网站. 我尝试用Xpath来做,但它显示了错误:-
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[4]/div/div1/div/div/div/div/div1"}
如图所示,我想提取部分:-“4.7/5星”,但由于是能见度模式,我无法提取信息。在
有人能帮我吗??
提前谢谢
当鼠标悬停在元素上时,将显示该元素。可能是使用AJAX查询。您需要执行鼠标悬停,然后,当它显示时,捕捉文本。在
ActionChains
from selenium.webdriver.common.action_chains import ActionChains
element_to_hover = driver.find_element_by_xpath(...) hover_action = ActionChains(driver).move_to_element(element_to_hover) hover_action.perform()
(也许您需要在第2步和第3步之间
time.sleep(1)
。)编辑
已经过测试,并且可以工作:
相关问题 更多 >
编程相关推荐