我试图使用Python3、Selenium和2 2captcha在没有提交按钮的表单上提交recaptcha。我对selenium非常陌生,并且试图绕过https://id.rambler.ru/login-20/mail-registration网站上的captcha,所有的代码都很好,除了我不知道如何提交captcha令牌和给出captcha令牌之后的表单。
,这是到目前为止的代码
browser = webdriver.Chrome("chromedriver.exe")
browser.get('https://id.rambler.ru/login-20/mail-registration?')
time.sleep(7)
WebDriverWait(browser, 2).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name^='a-'][src^='https://www.google.com/recaptcha/api2/anchor?']"))) #https://www.google.com/recaptcha/api2/anchor?
WebDriverWait(browser, 2).until(EC.element_to_be_clickable((By.XPATH, "//span[@id='recaptcha-anchor']")))
print('recaptcha found')
time.sleep(7)
url = f'https://2captcha.com/in.php?key={api_key}&method=userrecaptcha&googlekey={site_key}&pageurl={page_url}&json=1&invisible=1'
req = requests.get(url)
print(req.json())
rid = req.json().get("request")
url2 = f"http://2captcha.com/res.php?key={api_key}&action=get&id={rid}&json=1"
time.sleep(2)
while True:
r2 = requests.get(url2)
print(r2.json())
if r2.json().get("status") == 1:
form_tokon = r2.json().get("request")
break
time.sleep(5)
print(form_tokon)
time.sleep(5)发布于 2021-08-03 18:09:50
captcha的全部目的是防止人们自动执行某些任务(例如您试图使用Selenium自动化的表单)。
Captcha代表完全自动化的公共图灵测试,用来区分计算机和人类。虽然可能有旁路,但是captchas会不断更新以关闭这些解决方案,因此您不太可能找到任何方法使用自动化工具来绕过captcha。
https://stackoverflow.com/questions/68639330
复制相似问题