Python SDK for captcha-solver API — reCAPTCHA, Turnstile, hCaptcha, GeeTest, Tencent, and more
Project description
captcha-solver-sdk
Python SDK for the captcha-solver API. Zero dependencies, supports reCAPTCHA, Turnstile, hCaptcha, GeeTest, Tencent, and more.
Install
pip install captcha-solver-sdk
Or from source:
pip install git+https://github.com/your-org/captcha-solver-sdk.git
Quick Start
from captcha_solver_sdk import CaptchaSolver
solver = CaptchaSolver(
api_key="sk_your_key_here",
base_url="https://api.your-domain.com" # or http://127.0.0.1:8900 for local
)
# reCAPTCHA v3
token = solver.recaptcha_v3(
website_url="https://example.com/login",
website_key="6LdyC2cUAAAAACGuDKpXeDorzUDWXmdqeg-xy696",
page_action="login"
)
# reCAPTCHA v2
token = solver.recaptcha_v2(
website_url="https://example.com",
website_key="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
)
# Cloudflare Turnstile
token = solver.turnstile(
website_url="https://example.com",
website_key="0x4AAAAAAADnPIDROrmt1Wwj"
)
# hCaptcha
token = solver.hcaptcha(
website_url="https://example.com",
website_key="10000000-ffff-ffff-ffff-000000000001"
)
# GeeTest v4
result = solver.geetest_v4(
website_url="https://gt4.geetest.com/",
captcha_id="e392e1d7fd421dc63325744d5a2b9c73"
)
# result: {"captcha_id", "lot_number", "pass_token", "gen_time", "captcha_output"}
# Cloudflare Five-second Shield
result = solver.cloudflare_challenge("https://protected-site.com")
cookie = result["clearance_cookie"]
ua = result["user_agent"]
# Image OCR
import base64
with open("captcha.png", "rb") as f:
text = solver.image_to_text(base64.b64encode(f.read()).decode())
# Tencent TCaptcha (Chinese)
result = solver.tencent(
website_url="https://example.com",
app_id="2043136173"
)
ticket = result["ticket"]
# Check balance
balance = solver.get_balance()
print(f"Balance: ${balance:.2f}")
Selenium Integration
from selenium import webdriver
from captcha_solver_sdk import CaptchaSolver
solver = CaptchaSolver(api_key="sk_...", base_url="https://api.example.com")
driver = webdriver.Chrome()
driver.get("https://example.com/login")
# Get sitekey from page
sitekey = driver.find_element("css selector", ".g-recaptcha").get_attribute("data-sitekey")
token = solver.recaptcha_v2(website_url=driver.current_url, website_key=sitekey)
# Inject token
driver.execute_script(f'document.getElementById("g-recaptcha-response").value = "{token}";')
driver.find_element("id", "submit").click()
Playwright Integration
from playwright.sync_api import sync_playwright
from captcha_solver_sdk import CaptchaSolver
solver = CaptchaSolver(api_key="sk_...", base_url="https://api.example.com")
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("https://example.com/login")
sitekey = page.get_attribute(".g-recaptcha", "data-sitekey")
token = solver.recaptcha_v2(website_url=page.url, website_key=sitekey)
page.evaluate(f'document.getElementById("g-recaptcha-response").value = "{token}"')
page.click("#submit")
Async Support
import asyncio
from captcha_solver_sdk import CaptchaSolver
async def main():
solver = CaptchaSolver(api_key="sk_...", base_url="https://api.example.com")
# Use asyncio.to_thread for non-blocking calls
token = await asyncio.to_thread(
solver.recaptcha_v3,
website_url="https://example.com",
website_key="6Lf...",
page_action="submit"
)
print(token)
asyncio.run(main())
Supported Types
| Method | Task Type | Returns |
|---|---|---|
recaptcha_v2() |
ReCaptchaV2TaskProxyLess | token string |
recaptcha_v3() |
ReCaptchaV3TaskProxyLess | token string |
turnstile() |
AntiTurnstileTaskProxyLess | token string |
cloudflare_challenge() |
CloudflareChallengeTask | {clearance_cookie, user_agent, cookies} |
hcaptcha() |
HCaptchaTaskProxyLess | token string |
geetest_v4() |
GeeTestTask (v4) | {lot_number, pass_token, ...} |
geetest_v3() |
GeeTestTask (v3) | {challenge, validate, seccode} |
image_to_text() |
ImageToTextTask | text string |
slider_gap() |
SliderTask | {x, trajectory} |
rotate() |
RotateCaptchaTask | {angle, confidence} |
tencent() |
TencentCaptchaTask | {ticket, randstr} |
netease() |
NetEaseCaptchaTask | {NECaptchaValidate} |
aws_waf() |
AntiAwsWafTask | {token, cookie} |
datadome() |
DataDomeTask | {token, cookie} |
solve() |
any | dict |
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 captcha_solver_sdk-1.1.0.tar.gz.
File metadata
- Download URL: captcha_solver_sdk-1.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96c6e6f8d481f605966d9185e2938c8b9b01d2b2c284362b497ff3f5df2444bd
|
|
| MD5 |
52dc0521c7d32389900ccfda82cd0245
|
|
| BLAKE2b-256 |
a16a6f9dcf5876b81a8f29a1406676d883872411a298db870f57c6c08daa8592
|
File details
Details for the file captcha_solver_sdk-1.1.0-py3-none-any.whl.
File metadata
- Download URL: captcha_solver_sdk-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39297428acb5bafe04ba8fca01415fff59547428e5b0d4be9c542af6f35c9003
|
|
| MD5 |
9dd434bf10dd902ef10a5c0d7849f74c
|
|
| BLAKE2b-256 |
4ea6f72570667019b70e2bf617ac5daf95e32ccf8aa46e6c76e3610c0b9aa416
|