1

所以基本上我正在尝试制作一个程序,自动为创建帐户时需要验证码的特定网站创建帐户。我正在尝试从 2captcha(验证码令牌提供者)获取令牌,然后将其存储在“g-recaptcha-response”中,但是当我运行程序时,我仍然停留在验证码网站上并要求验证码。

import requests
from time import sleep

api_key = "API-KEY"
site_key = "SITE-KEy"

headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36"
}

url = "https://www.nakedcph.com/en/auth/view?op=register"

with requests.Session() as s:
    captcha_id = s.post("http://2captcha.com/in.php?key={}&method=userrecaptcha&invisible=1&googlekey={}&pageurl={}".format(api_key, site_key, url)).text.split('|')[1]
    recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(api_key, captcha_id)).text
    print("solving captcha...")
    while "CAPCHA_NOT_READY" in recaptcha_answer:
        sleep(5)
        recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(api_key, captcha_id)).text
    recaptcha_answer = recaptcha_answer.split('|')[1]
    print(recaptcha_answer)
    data = {
        "firstName": "example",
        "email": "example",
        "password": "example",
        "termsAccepted": "true",
        "g-recaptcha-response": recaptcha_answer
    }
    r = s.post(url, data=data, headers=headers)
    print(r.status_code)
4

1 回答 1

1

您的问题不在验证码中。

  1. 当您注册一个帐户时,请求被发送到 /auth/submit 但您将数据发送到 /auth/view?op=register
  2. 您的请求不包含正确的标头 3._AntiCsrfToken is missing in your post data
于 2020-08-06T09:58:16.060 回答