Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

recaptcha-solver

English | 简体中文

Reusable Selenium helper for visible checkbox and audio reCAPTCHA challenges.

Use this Skill

Responsibilities

  • 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.

Setup and dependencies

  1. Make this repository available to the agent as the recaptcha-solver Skill.

  2. Create and activate a virtual environment in the target project (recommended):

    Windows PowerShell

    py -m venv .venv
    .\.venv\Scripts\Activate.ps1

    Linux/macOS

    python3 -m venv .venv
    source .venv/bin/activate
  3. 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, and SpeechRecognition.

  4. 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 -y

    macOS (Homebrew)

    brew install ffmpeg

    Ubuntu/Debian

    sudo apt update
    sudo apt install -y ffmpeg
  5. 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.

Automated flow

The complete flow normally runs without manual clicking:

  1. The project's Selenium code fills and submits the site's form once.
  2. It calls solve_recaptcha(driver, timeout=30) in the same browser session.
  3. The Skill waits for and solves the checkbox/audio challenge.
  4. 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.

Install

pip install -e .

Install FFmpeg separately for pydub audio conversion.

Minimal usage

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.

Problems it solves

  • 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-response has received a token.
  • Selenium remains inside an iframe after a failed attempt and later selectors stop working.

Support and limits

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.

Test

python -m unittest discover -s tests

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages