Skip to content

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

reCAPTCHA v3 Solver for Python requests, No Browser (CapMonster Cloud)

tests License: MIT Python 3.9+ requests

A minimal Python reCAPTCHA v3 solver: it finds the sitekey and action on the page and gets a high-score v3 token from the official CapMonster Cloud reCAPTCHA v3 solver Python SDK. No browser is required. Use it for forms and APIs you own or are allowed to automate that check reCAPTCHA v3 scores.

What this example does

  1. Downloads the page with requests and extracts the sitekey from api.js?render=... or grecaptcha.execute(...).
  2. Reads the action name the page uses (for example login or submit) and detects reCAPTCHA Enterprise.
  3. Requests a token with RecaptchaV3ProxylessRequest, minScore and pageAction.
  4. Prints the token and, if you pass --post-url, sends it to your endpoint.

By default it runs on the public demo page lessons.zennolab.com.

Requirements

Quick start

git clone https://github.com/CapMonsterCloud/python-requests-recaptcha-v3-solver.git
cd python-requests-recaptcha-v3-solver
pip install -r requirements.txt

export CAPMONSTER_API_KEY=your_key        # Windows: set CAPMONSTER_API_KEY=your_key
python examples/solve_recaptcha_v3.py
python examples/solve_recaptcha_v3.py --url https://your-site.example/login --min-score 0.7 \
    --post-url https://your-site.example/api/login

Tests (offline):

pytest -q

How it works

  • v3 has no widget. There is nothing to click and usually no data-sitekey. extract_v3_params() reads the key from the render= parameter of api.js or from the first argument of grecaptcha.execute().
  • The action must match. The site's backend compares the action inside the token with what it expects. The script takes the action from the page code and lets you override it with --action when it is built dynamically.
  • Score is a request, not a guarantee. minScore (0.1-0.9, clamped by clamp_score()) asks for a token with at least that score. Match the threshold the target site enforces (Google's default is 0.5); very high values such as 0.9 increase the number of failed attempts.
  • Enterprise switch. If the page loads enterprise.js or calls grecaptcha.enterprise, the request is sent with isEnterprise=True.

reCAPTCHA v3 token basics

  • The token is sent to the site's backend (usually in a g-recaptcha-response field or an API header); there is no widget to fill.
  • A v3 token is single-use and lives about 2 minutes. Request a new token for every submission and send it right away.
  • The action and the page URL must match what the site expects, otherwise the backend rejects the token even if the score is high.

Common errors

Symptom Cause and fix
ValueError: reCAPTCHA v3 sitekey not found The script is loaded from a bundle. Search the JS files for execute( and pass the page that contains it, or read the key in DevTools.
Backend returns action-mismatch or similar The action differs from the one in the token. Pass the exact value with --action.
Token works once, then the site asks again v3 tokens are single-use and live about 2 minutes. Request a new token for every submission.
Low score reported by the site Raise --min-score towards the site's threshold and keep the same User-Agent and cookies when submitting. If the solution contains a userAgent, use it when you submit the token.
[ERROR_ZERO_BALANCE] / [ERROR_KEY_DOES_NOT_EXIST] Top up the balance or check the API key.

Get an API key

This example needs a CapMonster Cloud account and API key. Register and get the key on the reCAPTCHA v3 solver page. There you will also find pricing and the API description. New users can ask support for a $0.10 test balance after registering.

Responsible use

Use this code only with websites you own or are explicitly permitted to automate. Follow their terms of service and applicable laws, and keep your API key secret.

Links


reCAPTCHA is a trademark of Google LLC. CapMonster Cloud is not affiliated with or endorsed by Google.