NopeCHA
API bindings for the NopeCHA CAPTCHA service.
Installation
To install from PyPI, run python3 -m pip install nopecha.
API Usage
This package provides API wrappers for the following http packages:
Note: You will need to install the http package you want to use separately
(except for urllib, as it's built-in but not recommended).
Requests example
from nopecha.api.requests import RequestsAPIClient
api = RequestsAPIClient("YOUR_API_KEY")
solution = api.solve_hcaptcha("b4c45857-0e23-48e6-9017-e28fff99ffb2", "https://nopecha.com/demo/hcaptcha#easy")
print("token is", solution["data"])
Async HTTPX example
from nopecha.api.httpx import AsyncHTTPXAPIClient
async def main():
api = AsyncHTTPXAPIClient("YOUR_API_KEY")
solution = await api.solve_hcaptcha("b4c45857-0e23-48e6-9017-e28fff99ffb2", "https://nopecha.com/demo/hcaptcha#easy")
print("token is", solution["data"])
asyncio.run(main())
Extension builder
This package also provides a extension builder for Automation builds which includes:
- downloading the extension
- updating the extension
- updating the extension's manifest to include your settings
Example
from nopecha.extension import build_chromium
# will download the extension to the current working directory
output = build_chromium({
"key": "YOUR_API_KEY",
})
# custom output directory
from pathlib import Path
output = build_chromium({
"key": "YOUR_API_KEY",
}, Path("extension"))
You can plug the output path directly into your browser's extension manager to load the extension:
import undetected_chromedriver as uc
from nopecha.extension import build_chromium
output = build_chromium({
"key": "YOUR_API_KEY",
})
options = uc.ChromeOptions()
options.add_argument(f"load-extension={output}")
Building
To build from source, you will need to install
build
(python3 -m pip install --upgrade build ).
Then simply run python3 -m build to build the package.
Uploading to PyPI
To upload to PyPI, you will need to install
twine
(python3 -m pip install --upgrade twine).
Then simply run python3 -m twine upload dist/* to upload the package.
Migrate from v1
If you are migrating from v1, you will need to update your code to use the new client classes.
V1 was synchronous only, using the requests HTTP library. V2 supports both synchronous and asynchronous code, and multiple HTTP libraries.
To migrate, you will need to:
- Install the http library you want to use (requests, aiohttp, httpx) or use the built-in urllib.
- Replace
nopecha.api_keywith creating a client instance.
# Before
import nopecha
nopecha.api_key = "YOUR_API_KEY"
# Now
from nopecha.api.requests import RequestsAPIClient
client = RequestsAPIClient("YOUR_API_KEY")
- Replace
nopecha.Token.solve()/nopecha.Recognition.solve()/nopecha.Balance.get()with the appropriate method on the client instance.
# Before
import nopecha
nopecha.api_key = "..."
clicks = nopecha.Recognition.solve(
type='hcaptcha',
task='Please click each image containing a cat-shaped cookie.',
image_urls=[f"https://nopecha.com/image/demo/hcaptcha/{i}.png" for i in range(9)],
)
print(clicks)
token = nopecha.Token.solve(
type='hcaptcha',
sitekey='ab803303-ac41-41aa-9be1-7b4e01b91e2c',
url='https://nopecha.com/demo/hcaptcha',
)
print(token)
balance = nopecha.Balance.get()
print(balance)
# Now
from nopecha.api.requests import RequestsAPIClient
client = RequestsAPIClient("YOUR_API_KEY")
clicks = client.recognize_hcaptcha(
'Please click each image containing a cat-shaped cookie.',
[f"https://nopecha.com/image/demo/hcaptcha/{i}.png" for i in range(9)],
)
print(clicks)
token = client.solve_hcaptcha(
'ab803303-ac41-41aa-9be1-7b4e01b91e2c',
'https://nopecha.com/demo/hcaptcha',
)
print(token)
balance = client.status()
print(balance)
Metadata
Release files for nopecha 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nopecha-2.0.1.tar.gz | 10.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nopecha-2.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 24.1 kB
Release files / nopecha-2.0.1.tar.gz
| Download URL | nopecha-2.0.1.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44f41fff0a9ca0943d27cd996ed083782b3bf930c49f5bd2bffc04a847d1f470
|
|
BLAKE2b-256 checksum How to use checksums |
de8605d77a476d1d9fd868a862ab2982a0ceedcb6861f393a0c8a8991ceca40d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.3
|
Release files / nopecha-2.0.1-py2.py3-none-any.whl
| Download URL | nopecha-2.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ad7738e93df0d7ab38d35e0a9cd400f99d6c583c7c4cdc88036ff452bdbe7661
|
|
BLAKE2b-256 checksum How to use checksums |
60797b46ed6d0688fa1e9a6ec62d97ab540e9b633c1f92f4c3595fcb31627477
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.3
|
Security for nopecha 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.