1

我正在尝试使用 Python3、Selenium 和 2captcha 在没有提交按钮的表单上提交 recaptcha。我对 selenium 很陌生,并试图绕过网站上的验证码https://id.rambler.ru/login-20/mail-registration 所有代码都工作正常,除了我不知道如何提交验证码令牌和给出验证码令牌后的表格。

这是到目前为止的代码

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)
4

1 回答 1

-1

验证码的全部意义在于防止人们自动化某些任务(例如您尝试使用 Selenium 自动化的表单)。

Captcha 代表完全自动化的公共图灵测试,以区分计算机和人类。尽管可能会绕过验证码,但验证码会不断更新以关闭这些变通办法,因此您不太可能找到使用自动化工具绕过验证码的任何方法。

于 2021-08-03T18:09:50.983 回答