Skip to main content

Universal captcha solver for Playwright automation — hCaptcha + reCAPTCHA v2 via NopeCHA API

Project description

auto-captcha

Universal captcha solver for Playwright browser automation. Detects hCaptcha and reCAPTCHA v2, solves them via the NopeCHA API, and injects tokens — so your scripts never get stuck.

Works as a Python library, CLI tool, MCP server, and Hermes skill.

Install

pip install auto-captcha
python -m playwright install chromium

# Or from source
git clone https://github.com/interfluve-wav/auto-captcha.git
cd auto-captcha
pip install -e ".[all]"

Quick Start (1 line)

from auto_captcha import smart_page

with smart_page(api_key="your-key") as page:
    page.goto("https://protected-site.com")
    page.fill("#email", "user@example.com")
    page.click("#submit")   # captcha auto-solved

Three Ways to Use

1. smart_page() — Context Manager (easiest)

from auto_captcha import smart_page

with smart_page(api_key="your-key") as page:
    page.goto("https://example.com")
    page.fill("#email", "user@test.com")
    page.click("#submit")
    print(page.captcha_log)  # [{'type': 'hcaptcha', 'status': 'solved'}]

2. SmartPage — Wrap Existing Browser

from auto_captcha import SmartPage
from playwright.sync_api import sync_playwright

pw = sync_playwright().start()
browser = pw.chromium.launch(headless=True)
page = SmartPage(browser.new_page(), api_key="your-key")

page.goto("https://example.com")
page.fill("#input", "value")

3. CaptchaSolver — Full Control

from auto_captcha import CaptchaSolver

solver = CaptchaSolver(api_key="your-key")

captchas = solver.detect(page)       # [{'type': 'hcaptcha', 'sitekey': '...'}]
token = solver.solve("hcaptcha", sitekey, url)   # CaptchaResult(success=True, token='...')
solver.inject(page, "hcaptcha", token)
results = solver.auto_solve(page)    # detect + solve + inject

CLI

# Check credits
auto-captcha credits --key YOUR_KEY

# Detect captchas
auto-captcha detect --url https://example.com --key YOUR_KEY

# Solve captchas
auto-captcha solve --url https://example.com --key YOUR_KEY

MCP Server (for AI agents)

Works with Claude Code, OpenClaw, Cursor, and any MCP-compatible agent.

# Add to Claude Code
claude mcp add auto-captcha -- python -m auto_captcha.mcp_server

# Or configure in MCP config
{
  "mcpServers": {
    "auto-captcha": {
      "command": "python",
      "args": ["-m", "auto_captcha.mcp_server"],
      "env": {"NOPECHA_API_KEY": "your-key"}
    }
  }
}

Provides three MCP tools:

  • captcha_detect — detect captchas on a URL
  • captcha_solve — detect and solve all captchas
  • captcha_credits — check NopeCHA credit balance

Hermes Skill

Copy the hermes-skill/ directory to ~/.hermes/skills/auto-captcha/ and set NOPECHA_API_KEY in your .env.

Supported Captcha Types

Type Detection Speed Reliability
hCaptcha (checkbox) iframe + DOM 10-40s High
hCaptcha (enterprise) iframe + DOM 10-40s High
reCAPTCHA v2 iframe + DOM 60-120s+ Medium (queue)

Not supported: reCAPTCHA v3 (score-based, no challenge), Cloudflare Turnstile, FunCAPTCHA

Pitfalls

  • reCAPTCHA queues are slow — can take 60-120+ seconds during peak
  • Each solve costs 1 credit — check with solver.get_credits()
  • Headless detection — some sites block headless; use headless=False
  • Lazy-loaded captchas — add time.sleep() after actions that might trigger them

NopeCHA API Key

Get free credits at nopecha.com. Set as environment variable:

export NOPECHA_API_KEY="your-key"

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auto_captcha-0.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auto_captcha-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file auto_captcha-0.1.0.tar.gz.

File metadata

  • Download URL: auto_captcha-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for auto_captcha-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e077369d7488a225c76025db3370ebba5b1e8b05b353b14d5b30cbca22dbc7c6
MD5 6c951bf774983145d496a909a936c9ed
BLAKE2b-256 31766dc63637d886633306576f365979dc0f872e7d2aa870056de5f4255cff91

See more details on using hashes here.

File details

Details for the file auto_captcha-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: auto_captcha-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for auto_captcha-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 83d14e1c198710b25a369d5f5d86d41e1563f0621c6d1622af8288cb6d9040c9
MD5 cccd0aa0d4355600591051c86b34667c
BLAKE2b-256 ef552b01cfc2a266c7dff9b145eb79ddbb08929d57a3c9f953b800faec925fd0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page