Fill a form with a captcha solving script using requests


New member
So basically the script running perfectly, I get the feedback that my Captcha has been solved. But the problem lies when the script enters the rest of the form's input.

Any idea where it is coming from?
import requests
from random import randint
from time import sleep

# Add these values
API_KEY = 'ApiKey'  # Your 2captcha API KEY
site_key = 'SiteKey'  # site-key, read the 2captcha docs on how to get this
url = 'https://site'  # example url
proxy = 'proxy'  # example proxy

proxy = {'http': 'http://' + proxy, 'https': 'https://' + proxy}

s = requests.Session()

# here we post site key to 2captcha to get captcha ID (and we parse it here too)
captcha_id ="{}&method=userrecaptcha&googlekey={}&pageurl={}".format(API_KEY, site_key, url), proxies=proxy).text.split('|')[1]
# then we parse gresponse from 2captcha response
recaptcha_answer = s.get("{}&action=get&id={}".format(API_KEY, captcha_id), proxies=proxy).text
print("solving ref captcha...")
while 'CAPCHA_NOT_READY' in recaptcha_answer:
    recaptcha_answer = s.get("{}&action=get&id={}".format(API_KEY, captcha_id), proxies=proxy).text
recaptcha_answer = recaptcha_answer.split('|')[1]

# we make the payload for the post data here, use something like mitmproxy or fiddler to see what is needed
payload = {

    'username' : 'username',
    'password' : 'password' , 
    'password_again' : 'password' , 
    'email' : '' , 

    'key': 'value',
    'gresponse': recaptcha_answer # This is the response from 2captcha, which is needed for the post request to go through.


# then send the post request to the url
response ='https://site',payload, proxies=proxy)


New member
You only need to change 'gresponse' to 'g-recaptcha-response' and it's working perfectly