See: https://captchas.online/ for a fast and cheap unlimited captcha solving...
Installation
This package can be installed with Pip:
pip3 install captchasonline
Configuration
CaptchasOnline instance can be created like this:
from captchasonline import CaptchasOnline
solver = CaptchasOnline('YOUR_API_KEY')
Async
from captchasonline import AsyncCaptchasOnline
solver = AsyncCaptchasOnline('YOUR_API_KEY')
Also, there are a few options that can be configured:
config = {
'server': 'captchas.online',
'apiKey': 'YOUR_API_KEY',
'softId': 123,
'callback': 'https://your.site/result-receiver',
'defaultTimeout': 120,
'recaptchaTimeout': 600,
'pollingInterval': 10,
'extendedResponse': False
}
solver = CaptchasOnline(**config)
CaptchasOnline instance options
| Option | Default value | Description |
|---|---|---|
| server | captchasonline |
API server. You can set it to rucaptcha.com if your account is registered there |
| softId | 4580 | your software ID obtained after publishing in [2captcha software catalog] |
| callback | - | URL of your web server that receives the captcha recognition result. The URL should be first registered in [pingback settings] of your account |
| defaultTimeout | 120 | Polling timeout in seconds for all captcha types except reCAPTCHA. Defines how long the module tries to get the answer from the res.php API endpoint |
| recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from the res.php API endpoint |
| pollingInterval | 10 | Interval in seconds between requests to the res.php API endpoint. Setting values less than 5 seconds is not recommended |
| extendedResponse | None | Set to True to get the response with additional fields or in more practical format (enables JSON response from res.php API endpoint). Suitable for ClickCaptcha, Canvas |
To get the answer manually use get_result method
Solve captcha
When you submit any image-based CAPTCHA, you can provide additional options to help 2captcha workers solve it properly.
Captcha options
| Option | Default Value | Description |
|---|---|---|
| numeric | 0 | Defines if the captcha contains numeric or other symbols [see more info in the API docs][post options] |
| minLen | 0 | minimal answer length |
| maxLen | 0 | maximum answer length |
| phrase | 0 | defines if the answer contains multiple words or not |
| caseSensitive | 0 | defines if the answer is case sensitive |
| calc | 0 | defines captcha requires calculation |
| lang | - | defines the captcha language; see the [list of supported languages] |
| hintImg | - | an image with a hint shown to workers with the captcha |
| hintText | - | hint or task text shown to workers with the captcha |
Below, you can find basic examples for every captcha type. Check out [examples directory] for more examples with all available options.
Normal Captcha
To bypass a normal captcha (distorted text on an image) use the following method. This method can also be used to recognize any text in an image.
result = solver.normal('path/to/captcha.jpg', param1=..., ...)
# OR
result = solver.normal('https://site-with-captcha.com/path/to/captcha.jpg', param1=..., ...)
reCAPTCHA v2
Use the following method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
result = solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
url='https://mysite.com/page/with/recaptcha',
param1=..., ...)
reCAPTCHA v3
This method provides a reCAPTCHA V3 solver and returns a token.
result = solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
url='https://mysite.com/page/with/recaptcha',
version='v3',
param1=..., ...)
GeeTest
Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON.
result = solver.geetest(gt='f1ab2cdefa3456789012345b6c78d90e',
challenge='12345678abc90123d45678ef90123a456b',
url='https://www.site.com/page/',
param1=..., ...)
Lemin Cropped Captcha
Use this method to solve the Lemin captcha. Returns JSON with an answer containing the following values: answer, challenge_id.
result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d',
div_id='lemin-cropped-captcha',
url='https://www.site.com/page/',
param1=..., ...)
Cloudflare Turnstile
Use this method to solve Cloudflare Turnstile. Returns JSON with the token.
result = solver.turnstile(sitekey='0x1AAAAAAAAkg0s2VIOD34y5',
url='http://mysite.com/',
data='foo',
pagedata='bar',
action='challenge',
useragent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36')
CaptchaFox
This method can be used to solve CaptchaFox using a token. Returns a token.
result = solver.captchafox(sitekey='sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH',
pageurl='https://mysite.com/page/with/captchafox',
userAgent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
proxy={'type': 'HTTPS',
'uri': 'login:password@IP_address:PORT'})
Other methods
send / get_result
These methods can be used for manual captcha submission and answer polling. The send() method supports sending any captcha
type, to specify the captcha type you must send value method manually, for example method='recaptcha' for solving reCaptcha.
Example for solving Normal captcha manually:
import time
. . . . .
id = solver.send(file='path/to/captcha.jpg')
time.sleep(20)
code = solver.get_result(id)
balance
Use this method to get your account's balance
balance = solver.balance()
Error handling
In case of an error, the captcha solver throws an exception. It's important to properly handle these cases. We recommend using try except to handle exceptions.
try:
result = solver.text('If tomorrow is Saturday, what day is today?')
except ValidationException as e:
# invalid parameters passed
print(e)
except NetworkException as e:
# network error occurred
print(e)
except ApiException as e:
# api respond with error
print(e)
except TimeoutException as e:
# captcha is not solved so far
print(e)
proxy={
'type': 'HTTPS',
'uri': 'login:password@IP_address:PORT'
}
Async calls
To use the async version, just replace CaptchasOnline with AsyncCaptchasOnline:
import asyncio
from captchasonline import AsyncCaptchasOnline
async def solve_captcha():
solver = AsyncCaptchasOnline('YOUR_API_KEY')
try:
recaptcha_result = await solver.recaptcha(...)
return recaptcha_result
except Exception as e:
print(e)
return None
if __name__ == '__main__':
result = asyncio.run(solve_captcha())
The AsyncCaptchasOnline class supports all the same methods and parameters as the synchronous CaptchasOnline class but operates asynchronously. Configuration is identical.
Solving Multiple Captchas in Parallel
One of the main advantages of using async support is the ability to solve multiple captchas concurrently:
async def solve_multiple_captchas():
solver = AsyncCaptchasOnline('YOUR_API_KEY')
# Start all tasks simultaneously
task1 = asyncio.create_task(solver.text('What color is the sky on a clear day?'))
task2 = asyncio.create_task(solver.text('What is 2+2?'))
task3 = asyncio.create_task(solver.text('Name of the planet we live on?'))
# Wait for all tasks to complete
results = await asyncio.gather(task1, task2, task3, return_exceptions=True)
return results
# This completes much faster than solving captchas sequentially
results = asyncio.run(solve_multiple_captchas())
Examples of solving all supported captcha types asynchronously are located in the [examples/async directory] directory.
Legacy Async Method
For backward compatibility, you can also use the traditional executor-based approach with the synchronous client:
import asyncio
import concurrent.futures
from captchasonline import CaptchasOnline
API_KEY = "YOUR_API_KEY"
image = "data:image/png;base64,iVBORw0KGgoA..."
async def captchaSolver(image):
loop = asyncio.get_running_loop()
with concurrent.futures.ThreadPoolExecutor() as pool:
result = await loop.run_in_executor(pool, lambda: CaptchasOnline(API_KEY).normal(image))
return result
captcha_result = asyncio.run(captchaSolver(image))
Get in touch
License
The code in this repository is licensed under the MIT License. See the LICENSE file for more details.
Graphics and Trademarks
The graphics and trademarks included in this repository are not covered by the MIT License. Please contact support for permissions regarding the use of these materials.
Metadata
Release files for captchasonline 1.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 | Actions |
|---|---|---|---|---|
| captchasonline-1.0.1.tar.gz | 32.1 kB | Without provenance | Details for captchasonline-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| captchasonline-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for captchasonline-1.0.1-py3-none-any.whl |
Total release size: 62.3 kB
Release files / captchasonline-1.0.1.tar.gz
| Download URL | captchasonline-1.0.1.tar.gz |
|---|---|
| Size | 32.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd8a728a32ecfa0cd5c29dad53f1cc5a8d2a24183c87c9f49358eaaf022be531
|
|
BLAKE2b-256 checksum How to use checksums |
7caa7681b3351d26e8d20d57321bf4a885a1c1cd177c1f57cf3bedc54092c53d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / captchasonline-1.0.1-py3-none-any.whl
| Download URL | captchasonline-1.0.1-py3-none-any.whl |
|---|---|
| Size | 30.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7282621dd2bf5c1b4e70d8fe31ad5e572f803d3ec4566f7fb19d526e81da4df8
|
|
BLAKE2b-256 checksum How to use checksums |
c740d94f65df8ffae4e5a3a49341fbdcafe57251f308748e21a37616dc9049bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for captchasonline 1.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.