Examples of solving popular captcha types with
captcha-solver-api,
Selenium, and
seleniumbase.
Each example shows how to:
- Open a page and collect captcha parameters.
- Send a task to Captcha Solver.
- Apply the solution in the browser.
- Check that the page accepted the solution.
Requirements:
- Python 3.9 or newer
- Google Chrome
- A Captcha Solver API key with a positive balance
git clone https://github.com/captcha-solver-api/captcha-solver-selenium-python-examples.git
cd captcha-solver-selenium-python-examples
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
cp .env.example .envOn Windows:
.venv\Scripts\Activate.ps1
Copy-Item .env.example .envSet your API key in .env:
CAPTCHA_API_KEY=your_api_keypython examples/recaptcha_v2.pyThe reCAPTCHA v2 example uses the official Google demo by default. Set
TARGET_URL in .env to run another example against a page you are
authorized to test.
| Captcha | File |
|---|---|
| reCAPTCHA v2 | recaptcha_v2.py |
| reCAPTCHA v2 + proxy | recaptcha_v2_proxy.py |
| reCAPTCHA v2 callback | recaptcha_v2_callback_variant1.py |
| reCAPTCHA v2 callback, automatic discovery | recaptcha_v2_callback_variant2.py |
| reCAPTCHA v2 callback + proxy | recaptcha_v2_callback_proxy.py |
| reCAPTCHA v3 | recaptcha_v3.py |
| reCAPTCHA v3 interception | recaptcha_v3_extended_js_script.py |
| Cloudflare Turnstile | cloudflare_turnstile.py |
| Cloudflare Challenge | cloudflare_challenge_page.py |
| Tencent CAPTCHA | tencent.py |
| Image captcha, screenshot | normal_captcha_screenshot.py |
| Image captcha, canvas | normal_captcha_canvas.py |
| Image captcha with parameters | normal_captcha_screenshot_params.py |
| Coordinates | coordinates.py |
Tencent requires your own target page and selectors:
TARGET_URL=https://your-site.example/tencent-captcha
TENCENT_TRIGGER_SELECTOR=#open-captcha
TENCENT_SUCCESS_SELECTOR=.verification-successLeave TENCENT_TRIGGER_SELECTOR empty if the page opens the captcha
automatically.
PROXY_TYPE=http
PROXY_ADDRESS=proxy.example.com
PROXY_PORT=8080
PROXY_LOGIN=
PROXY_PASSWORD=The browser and API task use the same proxy.
python -m pip install ruff
ruff check .
ruff format --check .