Reusable Selenium helper for visible checkbox and audio reCAPTCHA challenges.
- Your project: opens the page, finds the form fields, enters runtime credentials, clicks the site's business button, and decides whether login succeeded.
- This Skill: detects the visible reCAPTCHA, switches to audio when needed, downloads and recognizes the audio, retries transient failures, and verifies the response token.
-
Make this repository available to the agent as the
recaptcha-solverSkill. -
Create and activate a virtual environment in the target project (recommended):
Windows PowerShell
py -m venv .venv .\.venv\Scripts\Activate.ps1Linux/macOS
python3 -m venv .venv source .venv/bin/activate -
Install the Python dependencies and this package:
python -m pip install --upgrade pip python -m pip install -e /path/to/recaptcha-solver
This installs
selenium,pydub, andSpeechRecognition. -
Install FFmpeg for audio conversion. Choose one command for your operating system:
Windows (WinGet, recommended)
winget install --id Gyan.FFmpeg.Shared -e
Windows (Chocolatey)
choco install ffmpeg -ymacOS (Homebrew)
brew install ffmpeg
Ubuntu/Debian
sudo apt update sudo apt install -y ffmpeg
-
Verify the installation:
python -c "import selenium, pydub, speech_recognition; print('Python dependencies OK')" ffmpeg -version
The Skill does not automatically install FFmpeg because it is a system executable and automatic system changes require administrator permissions. Install it once using the command for your operating system.
The complete flow normally runs without manual clicking:
- The project's Selenium code fills and submits the site's form once.
- It calls
solve_recaptcha(driver, timeout=30)in the same browser session. - The Skill waits for and solves the checkbox/audio challenge.
- After success, the project's code submits the form again, unless the site automatically continues after verification.
The Skill does not know the target site's selectors, so the caller must provide those selectors. Never put credentials in the Skill; provide them at runtime through environment variables or a secret manager.
pip install -e .Install FFmpeg separately for pydub audio conversion.
import os
from selenium import webdriver
from recaptcha_solver import solve_recaptcha
driver = webdriver.Chrome()
driver.get("https://example.com/login")
driver.find_element("name", "username").send_keys(os.environ["LOGIN_USERNAME"])
driver.find_element("name", "password").send_keys(os.environ["LOGIN_PASSWORD"])
driver.find_element("css selector", "button[type='submit']").click()
solve_recaptcha(driver, timeout=30)
driver.find_element("css selector", "button[type='submit']").click()The package reads HTTPS_PROXY, HTTP_PROXY, https_proxy, or http_proxy; pass proxy_url to override. solve_recaptcha(driver, proxy_url=None, timeout=15, max_retries=3) returns True or raises RecaptchaError with the failed stage.
- A reCAPTCHA appears only several seconds after the first login submit.
- Selenium selects a hidden or invisible iframe instead of the visible checkbox.
- The checkbox click succeeds, but the challenge iframe needs audio mode.
- Audio downloads or Google speech recognition fail intermittently and need retries.
- Browser traffic uses a proxy but Python audio requests do not.
- The checkbox looks checked before
g-recaptcha-responsehas received a token. - Selenium remains inside an iframe after a failed attempt and later selectors stop working.
Supports delayed checkbox/audio challenges, proxy-aware audio download, speech-recognition retries, and token validation. Image challenges, site-specific anti-bot blocks, and human checks may require manual intervention. It does not replace the target site's login selectors, account management, Cookie persistence, or success-page detection. Never commit usernames, passwords, cookies, tokens, API keys, .env files, or real logs. Follow the target site's terms and applicable laws.
python -m unittest discover -s tests