Reusable captcha router with pluggable solver providers.
Project description
captcha-router
Reusable captcha router with pluggable providers.
Install
pip install .
Publish automation (GitHub Actions)
- Configure Trusted Publishers in PyPI:
- Production: workflow
/.github/workflows/publish.yml, environmentpypi - Test: workflow
/.github/workflows/publish-testpypi.yml, environmenttestpypi
- Bump
versioninpyproject.tomland commit. - For TestPyPI (release candidate), tag with
-rc:
git tag v0.1.1-rc1
git push origin v0.1.1-rc1
- For production PyPI, push a stable tag:
git tag v0.1.1
git push origin v0.1.1
Publish on version change
The workflow /.github/workflows/publish-on-version-change.yml is active for pushes to main when pyproject.toml changes.
Default behavior:
- Push to
mainwith a changedproject.versioninpyproject.toml-> publishes to PyPI. - If
pyproject.tomlchanged but version did not change -> publish is skipped.
Manual behavior:
- You can still run the workflow manually from GitHub Actions and choose
testpypiorpypi.
Supported providers
anticaptcha(alias:anti-captcha)2captcha(alias:twocaptcha)
Router methods
CaptchaRouter.list_providers(): returns all registered provider names and aliases.CaptchaRouter.list_provider_capabilities(include_aliases=False): returns provider -> supported captcha kinds.CaptchaRouter.get_supported_task_kinds(provider_name): returns supported captcha kinds for one provider.CaptchaRouter.list_supported_task_kinds(): returns union of captcha kinds across providers.CaptchaRouter.get_solver(provider_name=None, api_key=None, **kwargs): creates a solver instance and uses env fallbacks whenapi_keyis omitted.
Usage
1) Create a solver
from captcha_router import CaptchaRouter
solver = CaptchaRouter.get_solver(provider_name="anticaptcha", api_key="YOUR_KEY")
2) Solve a task
import asyncio
from captcha_router import CaptchaRouter, CaptchaTaskSpec
async def main():
solver = CaptchaRouter.get_solver(provider_name="anticaptcha", api_key="YOUR_KEY")
try:
result = await solver.solve_task(
CaptchaTaskSpec(
kind="recaptcha_v2",
params={
"website_url": "https://example.com",
"site_key": "SITE_KEY_HERE",
},
)
)
print(result.status, result.token, result.error)
finally:
await solver.close()
asyncio.run(main())
3) Inspect capabilities
from captcha_router import CaptchaRouter
print(CaptchaRouter.list_providers())
print(CaptchaRouter.list_provider_capabilities())
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
captcha_router-0.1.2.tar.gz
(9.7 kB
view details)
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_router-0.1.2.tar.gz.
File metadata
- Download URL: captcha_router-0.1.2.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebfeec0816c5d9c700e017ee99f4f7420c03159f0a6d927fd1b8ea49df9ee0d1
|
|
| MD5 |
76b4c69d0a4b3decd8097a81d6298561
|
|
| BLAKE2b-256 |
251a3e93c7a0f12845b847859b14423b6ac51b6f9019b3a98abb55e265c078dc
|
File details
Details for the file captcha_router-0.1.2-py3-none-any.whl.
File metadata
- Download URL: captcha_router-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae0cae49a4694b94b54a1437f7ec79ba7d96ea16b56f9d1d652f6e069d9117e5
|
|
| MD5 |
4eba120f0f0aeddd9ebced6a1ff77327
|
|
| BLAKE2b-256 |
f68008263027de09b0535e5a1b5d9c78e9c88ceb27d5acdb31384fb28ae0e25d
|