我打开一个网站,upwork.com,做一些网页抓取,但试图点击一个元素是抛出一个错误。
验证码:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options: Options = webdriver.ChromeOptions()
options. add_experimental_option("detach", True)
driver = webdriver.Chrome(options=options)
driver.get ("https://www.upwork.com/nx/jobs/search/?from_recent_search=true&q=webscraping&sort=recency")
options.find_element("xpath", '//*[@id="job-1645717982262001664"]/div[1]/div/h3/a').click()
错误:
Traceback (most recent call last):
File "/Users/yatharthmahajan/Documents/Python/pythonProject/webscraper.py", line 8, in <module>
options.find_element("xpath", '//*[@id="job-1645717982262001664"]/div[1]/div/h3/a').click()
AttributeError: 'Options' object has no attribute 'find_element'
2条答案
按热度按时间nhn9ugyo1#
您正在
options
对象上使用find_element
方法,这是不正确的。您应该像下面这样在驱动程序对象上使用find_element
方法。wdebmtf22#
它应该是:
不包括: