【发布时间】:2023-03-10 18:39:01
【问题描述】:
专家您好!我是编程新手,我在寻找特定元素时遇到了问题。 这是我的代码。
from selenium import webdriver
from bs4 import BeautifulSoup as bs
import time
driver = webdriver.Chrome()
driver.get('https://www.ackerwines.com/auctions/?auctionId=1328')
time.sleep(3)
driver.find_element_by_xpath("//label[@for='checkbox']").click()
time.sleep(2)
driver.find_element_by_xpath("(//div[@id='sm-agree-button-wrap'])[3]").click()
time.sleep(5)
try:
driver.find_element_by_xpath("(//div[@class='elementor-shortcode'])[6]").click()
except:
driver.find_element_by_xpath("(//a[@class='elementor-icon'])[1]").click()
time.sleep(1)
driver.find_element_by_xpath("//input[@id='xoo-el-username']").click()
driver.find_element_by_xpath("//input[@id='xoo-el-username']").send_keys('malikibrahim6786@gmail.com')
driver.find_element_by_xpath("//input[@id='xoo-el-password']").click()
driver.find_element_by_xpath("//input[@id='xoo-el-password']").send_keys('Malik786')
driver.find_element_by_xpath("//input[@id='xoo-el-rememberme']").click()
driver.find_element_by_xpath("(//button[@type='submit'])[2]").click()
time.sleep(15)
prod = driver.find_element_by_xpath("//div[@class='auctionLotsList']")
print(prod)
我得到的错误是
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@class='auctionLotsList']"}
(Session info: chrome=87.0.4280.88)
【问题讨论】:
-
显而易见的解释是该元素不存在。是什么让您认为它应该存在?
标签: python web-scraping data-mining