captchaai 1.0.2__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {captchaai-1.0.2 → captchaai-2.0.0}/PKG-INFO +121 -46
- captchaai-1.0.2/readme.md → captchaai-2.0.0/README.md +118 -45
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/__init__.py +9 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/async_client.py +178 -12
- captchaai-2.0.0/captchaai/browser/__init__.py +18 -0
- captchaai-2.0.0/captchaai/browser/adapter.py +98 -0
- captchaai-2.0.0/captchaai/browser/engine.py +166 -0
- captchaai-2.0.0/captchaai/browser/scripts.py +456 -0
- captchaai-2.0.0/captchaai/browser/types.py +83 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/client.py +184 -20
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/core/config.py +1 -1
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/core/orchestrator.py +30 -10
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/core/registry.py +18 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/helpers/validation.py +24 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai.egg-info/PKG-INFO +121 -46
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai.egg-info/SOURCES.txt +8 -1
- captchaai-2.0.0/captchaai.egg-info/requires.txt +4 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/pyproject.toml +8 -2
- captchaai-2.0.0/tests/test_balance.py +93 -0
- captchaai-2.0.0/tests/test_browser.py +602 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/tests/test_client.py +12 -2
- {captchaai-1.0.2 → captchaai-2.0.0}/tests/test_validation.py +11 -1
- captchaai-1.0.2/captchaai.egg-info/requires.txt +0 -1
- {captchaai-1.0.2 → captchaai-2.0.0}/LICENSE +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/core/__init__.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/core/result.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/exceptions.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/helpers/__init__.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/helpers/extract.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/helpers/image.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/helpers/params.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/helpers/retry.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/py.typed +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/transport/__init__.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/transport/async_http.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/transport/base.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai/transport/sync_http.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai.egg-info/dependency_links.txt +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/captchaai.egg-info/top_level.txt +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/setup.cfg +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/tests/test_async_client.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/tests/test_exceptions.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/tests/test_extract.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/tests/test_orchestrator.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/tests/test_registry.py +0 -0
- {captchaai-1.0.2 → captchaai-2.0.0}/tests/test_thread_limit.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: captchaai
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: Official Python client for the CaptchaAI captcha-solving API.
|
|
5
5
|
Author-email: "Dev@Captchaai" <dev@captchaai.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -25,6 +25,8 @@ Requires-Python: >=3.10
|
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Dist: httpx
|
|
28
|
+
Provides-Extra: playwright
|
|
29
|
+
Requires-Dist: playwright>=1.40; extra == "playwright"
|
|
28
30
|
Dynamic: license-file
|
|
29
31
|
|
|
30
32
|
# CaptchaAI Python SDK
|
|
@@ -37,30 +39,33 @@ Dynamic: license-file
|
|
|
37
39
|
<a href="https://github.com/CaptchaAI/captchaai-python/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License" /></a>
|
|
38
40
|
</p>
|
|
39
41
|
|
|
40
|
-
CaptchaAI Python library — an official CAPTCHA solver and solving API client for reCAPTCHA v2/v3/Enterprise, Cloudflare Turnstile, Cloudflare Challenge, GeeTest v3, and image CAPTCHAs.
|
|
42
|
+
CaptchaAI Python library (`v2.0.0`, Python `>=3.10`, typed via `py.typed`) — an official CAPTCHA solver and solving API client for reCAPTCHA v2/v3/Enterprise, Cloudflare Turnstile, Cloudflare Challenge, GeeTest v3, CaptchaFox, Friendly Captcha, Lemin, and image CAPTCHAs, with optional Playwright browser automation.
|
|
41
43
|
|
|
42
|
-
Call one method per captcha type; the SDK handles HTTP, polling, retries, and typed error mapping.
|
|
44
|
+
Call one method per captcha type; the SDK handles HTTP, polling, retries, and typed error mapping via a sans-IO generator engine.
|
|
43
45
|
|
|
44
|
-
For full copy-paste examples of every captcha type and SDK feature, see [examples.md](https://github.com/CaptchaAI/captchaai-python/blob/main/examples.md).
|
|
46
|
+
For full copy-paste examples of every captcha type and SDK feature, see [examples.md](https://github.com/CaptchaAI/captchaai-python/blob/main/examples.md). For internal design details, see [ARCHITECTURE.md](ARCHITECTURE.md).
|
|
45
47
|
|
|
46
48
|
---
|
|
47
49
|
|
|
48
50
|
## Table of Contents
|
|
49
51
|
|
|
50
52
|
- [Examples](https://github.com/CaptchaAI/captchaai-python/blob/main/examples.md)
|
|
53
|
+
- [Packages](#packages)
|
|
51
54
|
- [Installation](#installation)
|
|
52
55
|
- [Configuration](#configuration)
|
|
53
56
|
- [Solve result](#solve-result)
|
|
54
57
|
- [Normal captcha](#normal-captcha)
|
|
55
58
|
- [Grid captcha](#grid-captcha)
|
|
56
59
|
- [BLS captcha](#bls-captcha)
|
|
57
|
-
- [reCAPTCHA v2
|
|
60
|
+
- [reCAPTCHA v2](#recaptcha-v2)
|
|
61
|
+
- [reCAPTCHA v3](#recaptcha-v3)
|
|
58
62
|
- [Cloudflare Turnstile](#cloudflare-turnstile)
|
|
59
63
|
- [Cloudflare Challenge](#cloudflare-challenge)
|
|
60
64
|
- [GeeTest v3](#geetest-v3)
|
|
61
|
-
- [CaptchaFox
|
|
62
|
-
- [Friendly Captcha
|
|
63
|
-
- [Lemin
|
|
65
|
+
- [CaptchaFox](#captchafox)
|
|
66
|
+
- [Friendly Captcha](#friendly-captcha)
|
|
67
|
+
- [Lemin](#lemin)
|
|
68
|
+
- [Browser automation (Playwright)](#browser-automation-playwright)
|
|
64
69
|
- [Other methods](#other-methods)
|
|
65
70
|
- [Error handling](#error-handling)
|
|
66
71
|
- [Proxies](#proxies)
|
|
@@ -69,15 +74,31 @@ For full copy-paste examples of every captcha type and SDK feature, see [example
|
|
|
69
74
|
|
|
70
75
|
---
|
|
71
76
|
|
|
77
|
+
## Packages
|
|
78
|
+
|
|
79
|
+
- **PyPI Package:** [https://pypi.org/project/captchaai/](https://pypi.org/project/captchaai/) (`pip install captchaai`)
|
|
80
|
+
- **GitHub Releases:** [https://github.com/CaptchaAI/captchaai-python/releases](https://github.com/CaptchaAI/captchaai-python/releases)
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
72
84
|
## Installation
|
|
73
85
|
|
|
86
|
+
Requires **Python 3.10+** (runtime dependency: `httpx`):
|
|
87
|
+
|
|
74
88
|
```bash
|
|
75
89
|
pip install captchaai
|
|
76
90
|
```
|
|
77
91
|
|
|
92
|
+
To enable optional Playwright browser helpers (`detect_captchas`, `get_captchas_params`, `inject_on_page`, `solve_url`):
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install "captchaai[playwright]"
|
|
96
|
+
playwright install chromium
|
|
97
|
+
```
|
|
98
|
+
|
|
78
99
|
## Configuration
|
|
79
100
|
|
|
80
|
-
Create a sync client with your API key from [CaptchaAI](https://captchaai.com/).
|
|
101
|
+
Create a sync client with your API key from [CaptchaAI](https://captchaai.com/). `CaptchaAI` validates the 32-character key length locally and reads the account thread cap via a startup `threadsinfo` call (`AsyncCaptchaAI.create()` delegates key validation to the startup `threadsinfo` call).
|
|
81
102
|
|
|
82
103
|
```python
|
|
83
104
|
from captchaai import CaptchaAI
|
|
@@ -85,7 +106,7 @@ from captchaai import CaptchaAI
|
|
|
85
106
|
solver = CaptchaAI(
|
|
86
107
|
api_key="YOUR_32_CHAR_API_KEY",
|
|
87
108
|
proxy="user:pass@host:port", # optional
|
|
88
|
-
proxytype="HTTP", # required when proxy is set
|
|
109
|
+
proxytype="HTTP", # required when proxy is set ("HTTP" or "HTTPS")
|
|
89
110
|
auto_retry=True,
|
|
90
111
|
base_url="https://ocr.captchaai.com",
|
|
91
112
|
thread_busy_timeout=120.0,
|
|
@@ -97,13 +118,13 @@ solver = CaptchaAI(
|
|
|
97
118
|
|--------|---------|-------------|
|
|
98
119
|
| `api_key` | *(required)* | 32-character CaptchaAI API key |
|
|
99
120
|
| `proxy` | `None` | `"user:pass@host:port"` applied to every solve |
|
|
100
|
-
| `proxytype` | `None` | `HTTP`
|
|
101
|
-
| `auto_retry` | `True` | `True` = SDK retries transient errors with backoff; `False` =
|
|
121
|
+
| `proxytype` | `None` | `"HTTP"` or `"HTTPS"` — required when `proxy` is set |
|
|
122
|
+
| `auto_retry` | `True` | `True` = SDK retries transient/proxy/busy-thread errors with backoff; `False` = fail fast (including local in-flight thread-cap gating) |
|
|
102
123
|
| `base_url` | `https://ocr.captchaai.com` | API host for `in.php` / `res.php` |
|
|
103
|
-
| `thread_busy_timeout` | `120.0` |
|
|
104
|
-
| `max_retries` | `None` | When set: `0` disables retries; `N > 0` enables up to N submit attempts (supersedes `auto_retry`) |
|
|
124
|
+
| `thread_busy_timeout` | `120.0` | Logical seconds budget to keep retrying while all account threads are busy |
|
|
125
|
+
| `max_retries` | `None` | When set: `0` disables retries (`auto_retry=False`); `N > 0` enables retries with up to `N` submit attempts (supersedes `auto_retry`) |
|
|
105
126
|
|
|
106
|
-
A bad key raises `InvalidKeyError` before any solve runs. Call `solver.close()` when finished to release the HTTP client.
|
|
127
|
+
A bad key raises `InvalidKeyError` before any solve runs. Call `solver.close()` when finished to release the HTTP client (`CaptchaAI` does not implement `__enter__`/`__exit__`; use `async with` on `AsyncCaptchaAI`).
|
|
107
128
|
|
|
108
129
|
---
|
|
109
130
|
|
|
@@ -127,7 +148,7 @@ Reuse `result.user_agent` on the target site when it is present (Enterprise, Clo
|
|
|
127
148
|
|
|
128
149
|
## Normal captcha
|
|
129
150
|
|
|
130
|
-
Solve a text/image captcha. `image` may be a file path, URL, data-URI, raw base64, or `bytes`.
|
|
151
|
+
Solve a text/image captcha. `image` may be a file path, URL, data-URI, raw base64, or `bytes`. PNG and GIF images are checked locally and must not exceed `1000px` in width or height.
|
|
131
152
|
|
|
132
153
|
```python
|
|
133
154
|
from captchaai import CaptchaAI
|
|
@@ -212,7 +233,7 @@ print(result.user_agent)
|
|
|
212
233
|
|
|
213
234
|
## reCAPTCHA v3
|
|
214
235
|
|
|
215
|
-
Solve reCAPTCHA v3. `min_score` defaults to `0.
|
|
236
|
+
Solve reCAPTCHA v3. `action` is required; `min_score` defaults to `None` (omitted unless set, e.g. `0.1`–`0.9`). Enterprise results include `user_agent`.
|
|
216
237
|
|
|
217
238
|
```python
|
|
218
239
|
# Standard v3
|
|
@@ -238,13 +259,12 @@ result = solver.recaptcha_v3(
|
|
|
238
259
|
|
|
239
260
|
## Cloudflare Turnstile
|
|
240
261
|
|
|
241
|
-
Solve a Cloudflare Turnstile challenge. Optional: `
|
|
262
|
+
Solve a Cloudflare Turnstile challenge. Optional: `cookies`, `user_agent`, `proxy`, `proxytype`.
|
|
242
263
|
|
|
243
264
|
```python
|
|
244
265
|
result = solver.turnstile(
|
|
245
266
|
sitekey="0x4AAAAAAAB...",
|
|
246
267
|
url="https://example.com",
|
|
247
|
-
action="login",
|
|
248
268
|
)
|
|
249
269
|
print(result.solution)
|
|
250
270
|
```
|
|
@@ -253,17 +273,16 @@ print(result.solution)
|
|
|
253
273
|
|
|
254
274
|
## Cloudflare Challenge
|
|
255
275
|
|
|
256
|
-
Solve Cloudflare Challenge (5s / Managed / Non-Interactive). **A working proxy is required
|
|
276
|
+
Solve Cloudflare Challenge (5s / Managed / Non-Interactive). **A working proxy is required** (`HTTP` or `HTTPS`, via client config or per-call override). Optional: `cookies`, `user_agent`.
|
|
257
277
|
|
|
258
278
|
```python
|
|
259
279
|
result = solver.cloudflare_challenge(
|
|
260
280
|
url="https://example.com",
|
|
261
|
-
|
|
262
|
-
proxy="user:pass@host:port", # required
|
|
281
|
+
proxy="user:pass@host:port", # required (or set at client level)
|
|
263
282
|
proxytype="HTTP", # required
|
|
264
|
-
user_agent="Mozilla/5.0 ...", #
|
|
283
|
+
user_agent="Mozilla/5.0 ...", # optional
|
|
265
284
|
)
|
|
266
|
-
print(result.solution) #
|
|
285
|
+
print(result.solution) # cf_clearance cookie / token
|
|
267
286
|
print(result.user_agent)
|
|
268
287
|
```
|
|
269
288
|
|
|
@@ -271,24 +290,24 @@ print(result.user_agent)
|
|
|
271
290
|
|
|
272
291
|
## GeeTest v3
|
|
273
292
|
|
|
274
|
-
Solve a GeeTest v3 challenge. Requires `gt`, `challenge`, and `url`. Optional: `
|
|
293
|
+
Solve a GeeTest v3 challenge. Requires `gt`, `challenge`, and `url`. Optional: `cookies`, `user_agent`, `proxy`, `proxytype`. Returns a structured dict with `challenge`, `validate`, and `seccode`.
|
|
275
294
|
|
|
276
295
|
```python
|
|
277
|
-
result = solver.
|
|
296
|
+
result = solver.geetest(
|
|
278
297
|
gt="YOUR_GT",
|
|
279
298
|
challenge="YOUR_CHALLENGE",
|
|
280
299
|
url="https://example.com",
|
|
281
300
|
)
|
|
282
|
-
print(result.solution["
|
|
283
|
-
print(result.solution["
|
|
284
|
-
print(result.solution["
|
|
301
|
+
print(result.solution["challenge"])
|
|
302
|
+
print(result.solution["validate"])
|
|
303
|
+
print(result.solution["seccode"])
|
|
285
304
|
```
|
|
286
305
|
|
|
287
306
|
---
|
|
288
307
|
|
|
289
|
-
## CaptchaFox
|
|
308
|
+
## CaptchaFox
|
|
290
309
|
|
|
291
|
-
Solve CaptchaFox. **A working proxy is required.**
|
|
310
|
+
Solve CaptchaFox. **A working proxy is required.** Returns the solution token and a `user_agent` to reuse on the target site.
|
|
292
311
|
|
|
293
312
|
```python
|
|
294
313
|
result = solver.captchafox(
|
|
@@ -298,11 +317,12 @@ result = solver.captchafox(
|
|
|
298
317
|
proxytype="HTTP",
|
|
299
318
|
)
|
|
300
319
|
print(result.solution)
|
|
320
|
+
print(result.user_agent)
|
|
301
321
|
```
|
|
302
322
|
|
|
303
323
|
---
|
|
304
324
|
|
|
305
|
-
## Friendly Captcha
|
|
325
|
+
## Friendly Captcha
|
|
306
326
|
|
|
307
327
|
Solve Friendly Captcha (v1 or v2). No proxy is required.
|
|
308
328
|
|
|
@@ -317,7 +337,7 @@ print(result.solution)
|
|
|
317
337
|
|
|
318
338
|
---
|
|
319
339
|
|
|
320
|
-
## Lemin
|
|
340
|
+
## Lemin
|
|
321
341
|
|
|
322
342
|
Solve a Lemin puzzle. `solution` is a dict with `answer` and `challenge_uuid`.
|
|
323
343
|
|
|
@@ -334,17 +354,64 @@ print(result.solution["challenge_uuid"])
|
|
|
334
354
|
|
|
335
355
|
---
|
|
336
356
|
|
|
357
|
+
## Browser automation (Playwright)
|
|
358
|
+
|
|
359
|
+
With `pip install "captchaai[playwright]"`, both `CaptchaAI` and `AsyncCaptchaAI` provide token-mode CAPTCHA detection, parameter extraction, solving, and page injection for Playwright (`reCAPTCHA v2/v3/Enterprise`, `Turnstile`, and `Cloudflare Challenge`):
|
|
360
|
+
|
|
361
|
+
```python
|
|
362
|
+
# One-shot: launch Chromium, detect CAPTCHAs, solve, and autofill
|
|
363
|
+
results = solver.solve_url("https://example.com", headless=True)
|
|
364
|
+
for item in results:
|
|
365
|
+
print(item.params.captcha_type, item.injected, item.error)
|
|
366
|
+
if item.result:
|
|
367
|
+
print(item.result.solution)
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
You can also pass an already-open Playwright `page` (left open after solving) or use the lower-level building blocks:
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
from captchaai import RECAPTCHA_INIT_HOOK_JS
|
|
374
|
+
|
|
375
|
+
# Install hook before navigation so dynamic callbacks / v3 actions are captured
|
|
376
|
+
page.context.add_init_script(RECAPTCHA_INIT_HOOK_JS)
|
|
377
|
+
page.goto("https://example.com")
|
|
378
|
+
|
|
379
|
+
# Option A: solve & autofill an already-open page
|
|
380
|
+
results = solver.solve_url(page=page)
|
|
381
|
+
|
|
382
|
+
# Option B: inspect and inject manually
|
|
383
|
+
detected = solver.detect_captchas(page) # e.g. ["recaptcha_v2", "turnstile"]
|
|
384
|
+
params_list = solver.get_captchas_params(page) # list[CaptchaParams]
|
|
385
|
+
for params in params_list:
|
|
386
|
+
task_id = solver.send(params.captcha_type, **params.to_api_params())
|
|
387
|
+
res = solver.get_result(params.captcha_type, task_id)
|
|
388
|
+
solver.inject_on_page(page, params, res)
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
> **Note:** `solve_url()` installs `RECAPTCHA_INIT_HOOK_JS` automatically when given a `url`. For `cloudflare_challenge`, `inject_on_page()` adds the `cf_clearance` cookie directly to `page.context`.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
337
395
|
## Other methods
|
|
338
396
|
|
|
339
397
|
### Thread usage
|
|
340
398
|
|
|
341
|
-
|
|
399
|
+
Check current thread usage:
|
|
342
400
|
|
|
343
401
|
```python
|
|
344
402
|
info = solver.threads_info()
|
|
345
403
|
# {"threads": 10, "working_threads": 3}
|
|
346
404
|
```
|
|
347
405
|
|
|
406
|
+
### Account balance
|
|
407
|
+
|
|
408
|
+
Check the raw account balance string:
|
|
409
|
+
|
|
410
|
+
```python
|
|
411
|
+
balance = solver.get_balance()
|
|
412
|
+
# e.g. "12.34"
|
|
413
|
+
```
|
|
414
|
+
|
|
348
415
|
### Manual submit / fetch
|
|
349
416
|
|
|
350
417
|
Submit now and poll later:
|
|
@@ -360,6 +427,17 @@ result = solver.get_result("recaptcha_v2", task_id)
|
|
|
360
427
|
print(result.solution)
|
|
361
428
|
```
|
|
362
429
|
|
|
430
|
+
### Supported types metadata
|
|
431
|
+
|
|
432
|
+
Inspect all 14 registered captcha types and their requirements:
|
|
433
|
+
|
|
434
|
+
```python
|
|
435
|
+
from captchaai import supported_types
|
|
436
|
+
|
|
437
|
+
types_map = supported_types()
|
|
438
|
+
print(list(types_map.keys()))
|
|
439
|
+
```
|
|
440
|
+
|
|
363
441
|
### Close
|
|
364
442
|
|
|
365
443
|
```python
|
|
@@ -420,7 +498,7 @@ except CaptchaAIError:
|
|
|
420
498
|
|
|
421
499
|
## Proxies
|
|
422
500
|
|
|
423
|
-
Proxies are supported at client level and per call. Format: `"user:pass@host:port"`. `proxytype` is required whenever a proxy is set (`HTTP
|
|
501
|
+
Proxies are supported at client level and per call. Format: `"user:pass@host:port"`. `proxytype` is required whenever a proxy is set (`HTTP` or `HTTPS`).
|
|
424
502
|
|
|
425
503
|
```python
|
|
426
504
|
# Client-level (every solve)
|
|
@@ -435,7 +513,7 @@ result = solver.recaptcha_v2(
|
|
|
435
513
|
sitekey="YOUR_SITEKEY",
|
|
436
514
|
url="https://example.com",
|
|
437
515
|
proxy="user:pass@other-host:port",
|
|
438
|
-
proxytype="
|
|
516
|
+
proxytype="HTTPS",
|
|
439
517
|
)
|
|
440
518
|
```
|
|
441
519
|
|
|
@@ -443,22 +521,19 @@ result = solver.recaptcha_v2(
|
|
|
443
521
|
|
|
444
522
|
## Async usage
|
|
445
523
|
|
|
446
|
-
|
|
524
|
+
`AsyncCaptchaAI` mirrors every solver, utility, and Playwright browser method as `async def`. Direct `AsyncCaptchaAI(...)` instantiation is blocked — always construct it via `await AsyncCaptchaAI.create(...)`, and close via `await solver.aclose()` or `async with`:
|
|
447
525
|
|
|
448
526
|
```python
|
|
449
527
|
import asyncio
|
|
450
528
|
from captchaai import AsyncCaptchaAI
|
|
451
529
|
|
|
452
530
|
async def main():
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
print(result.solution)
|
|
460
|
-
|
|
461
|
-
await solver.aclose()
|
|
531
|
+
async with await AsyncCaptchaAI.create(api_key="YOUR_32_CHAR_API_KEY") as solver:
|
|
532
|
+
result = await solver.turnstile(
|
|
533
|
+
sitekey="YOUR_SITEKEY",
|
|
534
|
+
url="https://example.com",
|
|
535
|
+
)
|
|
536
|
+
print(result.solution)
|
|
462
537
|
|
|
463
538
|
asyncio.run(main())
|
|
464
539
|
```
|