1

So basically I'm trying to make an program that automates creating accounts for this specific websites that needs captcha when creating an account. I'm trying to get a token from 2captcha (captcha token provider) which i then store in "g-recaptcha-response", but when i run the program im still stuck on the captcha site and it asks for captcha.

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)

1 Answers1

1

Your problem is not in the captcha.

  1. When you register an account, the request is sent to /auth/submit but you send the data to /auth/view?op=register
  2. Your request does not contain proper headers 3._AntiCsrfToken is missing in your post data
I_Can_Help
  • 581
  • 3
  • 4