我正在尝试使用Python中的selenium.webdriver.chrome从groceries.asda.com中提取产品信息
但是如果我转到一个特定的页面(https://groceries.asda.com/shelf/everyday-family-cereals/2-for-4-cereals/_/3097456947)并在googlechrome中查看它的源代码,我就找不到产品名称,所以我无法使用find\u element\u by \u xpath之类的方法
有人知道如何使用selenium从ASDA网站上提取产品名称吗
尝试了xpath,css选择器,它们都返回NoSuchElementException
from selenium import webdriver
url = "https://groceries.asda.com/shelf/everyday-family-cereals/2-for-4-cereals/_/3097456947"
driver = webdriver.Chrome()
driver.get(url)
nav = driver.find_element_by_xpath('//*[@id="listingsContainer-0bd93fc4-888f-52c5-1c47-5679e4aab507"]/div/div[1]/div[2]/div/div/div[2]/span[1]/a/span')
product = nav.text
print(product)
无接触异常
尝试这种方法-这应该使用“alt”属性打印所有产品详细信息
谢谢你的灵感。这是按计划进行的。谢谢你
相关问题 更多 >
编程相关推荐