Python 3.9+ RuCaptcha library with AIO module.
Project description
python-rucaptcha
Python 3.9+ library to solve CAPTCHAs automatically using RuCaptcha, 2Captcha, or DeathByCaptcha services.
What is this?
This library automates CAPTCHA solving by connecting to third-party services. When your code encounters a CAPTCHA, python-rucaptcha sends it to the service, waits for a human to solve it, and returns the solution to your application.
Supports 30+ CAPTCHA types:
- reCAPTCHA v2/v3, hCaptcha, Cloudflare Turnstile
- Image captchas, Audio captchas
- GeeTest, KeyCaptcha, Amazon WAF, Tencent
- And many more...
Quick Start
1. Install
pip install python-rucaptcha
2. Get an API Key
Sign up at RuCaptcha or 2Captcha, then copy your API key from the dashboard.
3. Solve a CAPTCHA
from python_rucaptcha import HCaptcha
# Your API key
key = "your_api_key_here"
# Solve hCaptcha
result = HCaptcha(aptcha_key=key).captcha_handler(site_url="https://example.com", site_key="abc123")
if result['code'] == 0:
print(f"Solved! Token: {result['token']}")
else:
print(f"Error: {result['message']}")
Solving Different CAPTCHA Types
reCAPTCHA v2:
from python_rucaptcha import ReCaptcha
result = ReCaptcha(api_key).captcha_handler(
site_url="https://example.com",
site_key="your_site_key"
)
Image CAPTCHA:
from python_rucaptcha import ImageCaptcha
result = ImageCaptcha(api_key).captcha_handler(
image_link="https://example.com/captcha.jpg"
)
ALTCHA:
from python_rucaptcha import AltchaCaptcha
from python_rucaptcha.core.enums import AltchaEnm
result = AltchaCaptcha(
rucaptcha_key=api_key,
websiteURL="https://example.com",
challengeURL="https://example.com/altcha/challenge",
method=AltchaEnm.AltchaTaskProxyless,
).captcha_handler()
Using async:
import asyncio
from python_rucaptcha import HCaptcha
async def solve():
result = await HCaptcha(api_key).aio_captcha_handler(
site_url="https://example.com",
site_key="abc123"
)
return result
token = asyncio.run(solve())
Supported CAPTCHA Types
| CAPTCHA | Module | Description |
|---|---|---|
| reCAPTCHA v2/v3 | ReCaptcha |
Google reCAPTCHA |
| hCaptcha | HCaptcha |
hCaptcha challenge |
| Cloudflare Turnstile | Turnstile |
Cloudflare protection |
| Image | ImageCaptcha |
Type the text from image |
| Audio | AudioCaptcha |
Listen and type audio |
| GeeTest | GeeTest |
Chinese geetest puzzles |
| KeyCaptcha | KeyCaptcha |
KeyCAPTCHA service |
| Amazon WAF | AmazonWaf |
AWS WAF challenge |
| ALTCHA | AltchaCaptcha |
ALTCHA challenge |
| Binance | BinanceCaptcha |
Token-based Binance challenge |
| Grid | GridCaptcha |
Select grid cells |
| Coordinates | CoordinatesCaptcha |
Click on coordinates |
| And 20+ more | ... | See full docs |
Switching Services
Use the same code with different services:
from python_rucaptcha import HCaptcha
from python_rucaptcha.core.enums import ServiceEnm
# Use 2Captcha (default)
result = HCaptcha("2captcha_key").captcha_handler(...)
# Use RuCaptcha
result = HCaptcha("rucaptcha_key", service_type=ServiceEnm.RuCaptcha).captcha_handler(...)
# Use DeathByCaptcha
result = HCaptcha("dbc_user:dbc_pass", service_type=ServiceEnm.DeathByCaptcha).captcha_handler(...)
Testing
# Set your API key
export RUCAPTCHA_KEY="your_key_here"
# Run tests
make tests
Documentation
For advanced usage, configuration options, and all CAPTCHA types, see the full documentation.
Support
- Telegram: pythoncaptcha
- Email: python-captcha@pm.me
- Issues: GitHub Issues
Changelog
See Releases for full changelog.
- v6.0 - Refactored to use msgspec (faster), API v2, dropped Python 3.8
- v5.3 - Added DeathByCaptcha support
- v5.2 - Added audio CAPTCHA solving
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_rucaptcha-6.6.0.tar.gz.
File metadata
- Download URL: python_rucaptcha-6.6.0.tar.gz
- Upload date:
- Size: 44.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
541e9bea04ea67850eb87d0b67af5105f587ff835be8da9e5e152d646d135cd8
|
|
| MD5 |
e2fe4a5c225309c2575843053e73fb46
|
|
| BLAKE2b-256 |
6dd0ae27a21ba8eb82baaeb7f61b8e93141c76443c2aeaa7474e7a0c8aa739c9
|
File details
Details for the file python_rucaptcha-6.6.0-py3-none-any.whl.
File metadata
- Download URL: python_rucaptcha-6.6.0-py3-none-any.whl
- Upload date:
- Size: 59.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cefc0f6e455d86f85a8e4061672e0cf1a9a6e919d33dd21807736c5fd78e2ee
|
|
| MD5 |
98f81ba090a8b8e990ac6053d92e336d
|
|
| BLAKE2b-256 |
abf13bd14f9cef7ac98cef54c1e1f270020a97681292e2ada8bef0e774670e9e
|