找到 reCAPTCHA 元素并点击它——Python + Selenium

我需要帮助。有网址:https://www.inipec.gov.it/cerca-pec/-/pecs/companies。我需要点击复选框验证码: 

http://img1.mukewang.com/614ed9960001470912790792.jpg

我的代码看起来像:


import os, urllib.request, requests, datetime, time, random, ssl, json, codecs, csv, urllib

from urllib.request import Request, urlopen

from urllib.request import urlretrieve

from datetime import datetime

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

from selenium.common.exceptions import NoSuchElementException

from selenium.webdriver.common.by import By

from selenium.webdriver.support.ui import WebDriverWait 

from selenium.webdriver.support import expected_conditions as EC

from selenium.common.exceptions import NoAlertPresentException

from selenium.webdriver.chrome.options import Options


chromedriver = "chromedriver"

os.environ["webdriver.chrome.driver"] = chromedriver

chrome_options = webdriver.ChromeOptions()

driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chrome_options)

driver.get("https://www.inipec.gov.it/cerca-pec/-/pecs/companies")

driver.switch_to_default_content()

element = driver.find_elements_by_css_selector('iframe')[1]

driver.switch_to_frame(element)


driver.find_elements_by_xpath('//*[@id="recaptcha-anchor"]/div[1]').click()

在执行过程中,出现错误:


driver.find_elements_by_xpath('//*[@id="recaptcha-anchor"]/div 1 ').click() AttributeError: 'list' 对象没有属性 'click'


请帮助修复它。


qq_遁去的一_1
浏览 301回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python