2captcha-python 1.5.0__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.
Files changed (44) hide show
  1. {2captcha_python-1.5.0 → 2captcha_python-2.0.0/2captcha_python.egg-info}/PKG-INFO +102 -40
  2. 2captcha_python-2.0.0/2captcha_python.egg-info/SOURCES.txt +16 -0
  3. 2captcha_python-2.0.0/2captcha_python.egg-info/requires.txt +3 -0
  4. 2captcha_python-1.5.0/README.md → 2captcha_python-2.0.0/PKG-INFO +120 -38
  5. 2captcha_python-1.5.0/2captcha_python.egg-info/PKG-INFO → 2captcha_python-2.0.0/README.md +86 -57
  6. {2captcha_python-1.5.0 → 2captcha_python-2.0.0}/setup.py +4 -4
  7. 2captcha_python-2.0.0/twocaptcha/__init__.py +20 -0
  8. {2captcha_python-1.5.0 → 2captcha_python-2.0.0}/twocaptcha/api.py +8 -12
  9. 2captcha_python-2.0.0/twocaptcha/async_api.py +124 -0
  10. 2captcha_python-2.0.0/twocaptcha/async_solver.py +1120 -0
  11. 2captcha_python-2.0.0/twocaptcha/exceptions/__init__.py +0 -0
  12. 2captcha_python-2.0.0/twocaptcha/exceptions/api.py +6 -0
  13. 2captcha_python-2.0.0/twocaptcha/exceptions/solver.py +18 -0
  14. {2captcha_python-1.5.0 → 2captcha_python-2.0.0}/twocaptcha/solver.py +189 -45
  15. 2captcha_python-1.5.0/2captcha_python.egg-info/SOURCES.txt +0 -34
  16. 2captcha_python-1.5.0/2captcha_python.egg-info/requires.txt +0 -1
  17. 2captcha_python-1.5.0/tests/test_amazon_waf.py +0 -42
  18. 2captcha_python-1.5.0/tests/test_atb_captcha.py +0 -31
  19. 2captcha_python-1.5.0/tests/test_canvas.py +0 -89
  20. 2captcha_python-1.5.0/tests/test_capy.py +0 -38
  21. 2captcha_python-1.5.0/tests/test_coordinates.py +0 -84
  22. 2captcha_python-1.5.0/tests/test_cutcaptcha.py +0 -31
  23. 2captcha_python-1.5.0/tests/test_cybersiara.py +0 -32
  24. 2captcha_python-1.5.0/tests/test_datadome.py +0 -34
  25. 2captcha_python-1.5.0/tests/test_friendly_captcha.py +0 -29
  26. 2captcha_python-1.5.0/tests/test_funcaptcha.py +0 -44
  27. 2captcha_python-1.5.0/tests/test_geetest.py +0 -41
  28. 2captcha_python-1.5.0/tests/test_geetest_v4.py +0 -34
  29. 2captcha_python-1.5.0/tests/test_grid.py +0 -91
  30. 2captcha_python-1.5.0/tests/test_hcaptcha.py +0 -38
  31. 2captcha_python-1.5.0/tests/test_keycaptcha.py +0 -44
  32. 2captcha_python-1.5.0/tests/test_lemin.py +0 -42
  33. 2captcha_python-1.5.0/tests/test_mtcaptcha.py +0 -29
  34. 2captcha_python-1.5.0/tests/test_normal.py +0 -102
  35. 2captcha_python-1.5.0/tests/test_recaptcha.py +0 -66
  36. 2captcha_python-1.5.0/tests/test_rotate.py +0 -109
  37. 2captcha_python-1.5.0/tests/test_tencent.py +0 -29
  38. 2captcha_python-1.5.0/tests/test_text.py +0 -40
  39. 2captcha_python-1.5.0/tests/test_turnstile.py +0 -36
  40. 2captcha_python-1.5.0/twocaptcha/__init__.py +0 -15
  41. {2captcha_python-1.5.0 → 2captcha_python-2.0.0}/2captcha_python.egg-info/dependency_links.txt +0 -0
  42. {2captcha_python-1.5.0 → 2captcha_python-2.0.0}/2captcha_python.egg-info/top_level.txt +0 -0
  43. {2captcha_python-1.5.0 → 2captcha_python-2.0.0}/LICENSE +0 -0
  44. {2captcha_python-1.5.0 → 2captcha_python-2.0.0}/setup.cfg +0 -0
@@ -1,11 +1,11 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: 2captcha-python
3
- Version: 1.5.0
3
+ Version: 2.0.0
4
4
  Summary: Python module for easy integration with 2Captcha API
5
5
  Home-page: https://github.com/2captcha/2captcha-python/
6
6
  Author: 2Captcha
7
7
  Author-email: info@2captcha.com
8
- Keywords: 2captcha,captcha,api,captcha solver,reCAPTCHA,hCaptcha,FunCaptcha,Geetest,image captcha,Coordinates,Click Captcha,Geetest V4,Lemin captcha,Amazon WAF,Cloudflare Turnstile,Capy Puzzle,MTCaptcha,Friendly Captcha,Tencent,Cutcaptcha,DataDome,cybersiara
8
+ Keywords: 2captcha,captcha,api,captcha solver,reCAPTCHA,FunCaptcha,Geetest,image captcha,Coordinates,Click Captcha,Geetest V4,Lemin captcha,Amazon WAF,Cloudflare Turnstile,Capy Puzzle,MTCaptcha,Friendly Captcha,Tencent,Cutcaptcha,DataDome,cybersiara
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Operating System :: OS Independent
@@ -17,6 +17,19 @@ Requires-Python: >=3.6
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
19
  Requires-Dist: requests
20
+ Requires-Dist: httpx
21
+ Requires-Dist: aiofiles
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: keywords
29
+ Dynamic: license-file
30
+ Dynamic: requires-dist
31
+ Dynamic: requires-python
32
+ Dynamic: summary
20
33
 
21
34
  <a href="https://github.com/2captcha/2captcha-python"><img src="https://github.com/user-attachments/assets/a737d428-5233-4605-9d09-211fa213d069" width="82" height="30"></a>
22
35
  <a href="https://github.com/2captcha/2captcha-javascript"><img src="https://github.com/user-attachments/assets/4d3b4541-34b2-4ed2-a687-d694ce67e5a6" width="36" height="30"></a>
@@ -46,7 +59,7 @@ Examples of API requests for different captcha types are available on the [Pytho
46
59
  - [FunCaptcha](#funcaptcha)
47
60
  - [GeeTest](#geetest)
48
61
  - [GeeTest v4](#geetest-v4)
49
- - [hCaptcha](#hcaptcha)
62
+ - [Yandex Smart](#yandex-smart)
50
63
  - [Lemin Cropped Captcha](#lemin-cropped-captcha)
51
64
  - [Cloudflare Turnstile](#cloudflare-turnstile)
52
65
  - [Amazon WAF](#amazon-waf)
@@ -61,7 +74,7 @@ Examples of API requests for different captcha types are available on the [Pytho
61
74
  - [Friendly Captcha](#friendly-captcha)
62
75
  - [Cutcaptcha](#cutcaptcha)
63
76
  - [Tencent](#tencent)
64
- - [Datadome](#datadome)
77
+ - [DataDome](#datadome)
65
78
  - [CyberSiARA](#cybersiara)
66
79
  - [Other methods](#other-methods)
67
80
  - [send / get\_result](#send--get_result)
@@ -72,11 +85,11 @@ Examples of API requests for different captcha types are available on the [Pytho
72
85
  - [Async calls](#async-calls)
73
86
  - [Examples](#examples)
74
87
  - [Examples using Selenium](#examples-using-selenium)
75
- - [Useful articles](#useful-articles)
76
- - [Get in touch](#get-in-touch)
77
- - [Join the team 👪](#join-the-team-)
78
- - [License](#license)
79
- - [Graphics and Trademarks](#graphics-and-trademarks)
88
+ - [Useful articles](#useful-articles)
89
+ - [Get in touch](#get-in-touch)
90
+ - [Join the team 👪](#join-the-team-)
91
+ - [License](#license)
92
+ - [Graphics and Trademarks](#graphics-and-trademarks)
80
93
 
81
94
  ## Installation
82
95
 
@@ -96,6 +109,18 @@ from twocaptcha import TwoCaptcha
96
109
 
97
110
  solver = TwoCaptcha('YOUR_API_KEY')
98
111
  ```
112
+
113
+ <details>
114
+ <summary>Async</summary>
115
+
116
+ ```python
117
+ from twocaptcha import AsyncTwoCaptcha
118
+
119
+ solver = AsyncTwoCaptcha('YOUR_API_KEY')
120
+ ```
121
+
122
+ </details>
123
+
99
124
  Also, there are a few options that can be configured:
100
125
 
101
126
  ```python
@@ -107,6 +132,7 @@ config = {
107
132
  'defaultTimeout': 120,
108
133
  'recaptchaTimeout': 600,
109
134
  'pollingInterval': 10,
135
+ 'extendedResponse': False
110
136
  }
111
137
  solver = TwoCaptcha(**config)
112
138
  ```
@@ -121,7 +147,7 @@ solver = TwoCaptcha(**config)
121
147
  | 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 |
122
148
  | recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from the `res.php` API endpoint |
123
149
  | pollingInterval | 10 | Interval in seconds between requests to the `res.php` API endpoint. Setting values less than 5 seconds is not recommended |
124
- | 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 [hCaptcha](#hcaptcha), [ClickCaptcha](#clickcaptcha), [Canvas](#canvas) |
150
+ | 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](#clickcaptcha), [Canvas](#canvas) |
125
151
 
126
152
 
127
153
  > [!IMPORTANT]
@@ -245,19 +271,6 @@ result = solver.geetest_v4(captcha_id='e392e1d7fd421dc63325744d5a2b9c73',
245
271
  ```
246
272
 
247
273
 
248
- ### hCaptcha
249
-
250
- <sup>[API method description.](https://2captcha.com/2captcha-api#solving_hcaptcha)</sup>
251
-
252
- Use this method to solve the hCaptcha challenge. Returns a token to bypass the captcha.
253
- ```python
254
- result = solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001',
255
- url='https://www.site.com/page/',
256
- param1=..., ...)
257
-
258
- ```
259
-
260
-
261
274
  ### Lemin Cropped Captcha
262
275
 
263
276
  <sup>[API method description.](https://2captcha.com/2captcha-api#lemin)</sup>
@@ -271,6 +284,15 @@ result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d90
271
284
 
272
285
  ```
273
286
 
287
+ ### Yandex Smart
288
+
289
+ Use this method to solve Yandex Smart Captcha. Returns JSON with the token.
290
+ ```python
291
+ result = solver.yandex_smart(sitekey='0x1AAAAh45AAAAkg0s2VIOD34y5hy4h4h',
292
+ url='http://mysite.com/',
293
+ proxy={'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'},
294
+ 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')
295
+ ```
274
296
 
275
297
  ### Cloudflare Turnstile
276
298
 
@@ -424,7 +446,7 @@ result = solver.cutcaptcha(misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320'
424
446
 
425
447
  <sup>[API method description.](https://2captcha.com/2captcha-api#tencent)</sup>
426
448
 
427
- Use this method to solve Cutcaptcha. Returns a token.
449
+ Use this method to solve Tencent captcha. Returns a token.
428
450
  ```python
429
451
  result = solver.tencent(app_id="197326679",
430
452
  url="https://mysite.com/page/with/tencent",
@@ -467,7 +489,7 @@ result = solver.cybersiara(master_url_id='tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv',
467
489
 
468
490
  ### send / get_result
469
491
  These methods can be used for manual captcha submission and answer polling. The `send()` method supports sending any captcha
470
- type, to specify the captcha type you must send value `method` manually, for example `method='hcaptcha'` for solving hCapthca.
492
+ type, to specify the captcha type you must send value `method` manually, for example `method='recaptcha'` for solving reCaptcha.
471
493
  You can find the value of the `method` parameter in the [API documentation](https://2captcha.com/2captcha-api).
472
494
 
473
495
  Example for solving Normal captcha manually:
@@ -479,17 +501,6 @@ import time
479
501
  id = solver.send(file='path/to/captcha.jpg')
480
502
  time.sleep(20)
481
503
 
482
- code = solver.get_result(id)
483
- ```
484
- Example for solving hCaptcha manually:
485
- ```python
486
- import time
487
- . . . . .
488
- id = solver.send(sitekey='41b778e7-8f20-45cc-a804-1f1ebb45c579',
489
- url='https://2captcha.com/demo/hcaptcha?difficulty=easy',
490
- method='hcaptcha')
491
- print(id)
492
- time.sleep(20)
493
504
  code = solver.get_result(id)
494
505
  ```
495
506
 
@@ -535,7 +546,7 @@ except TimeoutException as e:
535
546
 
536
547
  ## Proxies
537
548
 
538
- You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha,
549
+ You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4,
539
550
  keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha, Tencent, DataDome, cybersiara.
540
551
 
541
552
 
@@ -551,7 +562,55 @@ proxy={
551
562
  ```
552
563
 
553
564
  ## Async calls
554
- You can also make async calls with [asyncio], for example:
565
+
566
+ To use the async version, just replace `TwoCaptcha` with `AsyncTwoCaptcha`:
567
+
568
+ ```python
569
+ import asyncio
570
+ from twocaptcha import AsyncTwoCaptcha
571
+
572
+ async def solve_captcha():
573
+ solver = AsyncTwoCaptcha('YOUR_API_KEY')
574
+
575
+ try:
576
+ recaptcha_result = await solver.recaptcha(...)
577
+ return recaptcha_result
578
+ except Exception as e:
579
+ print(e)
580
+ return None
581
+
582
+ if __name__ == '__main__':
583
+ result = asyncio.run(solve_captcha())
584
+ ```
585
+
586
+ The `AsyncTwoCaptcha` class supports all the same methods and parameters as the synchronous `TwoCaptcha` class but operates asynchronously. Configuration is identical.
587
+
588
+ ### Solving Multiple Captchas in Parallel
589
+
590
+ One of the main advantages of using async support is the ability to solve multiple captchas concurrently:
591
+
592
+ ```python
593
+ async def solve_multiple_captchas():
594
+ solver = AsyncTwoCaptcha('YOUR_API_KEY')
595
+
596
+ # Start all tasks simultaneously
597
+ task1 = asyncio.create_task(solver.text('What color is the sky on a clear day?'))
598
+ task2 = asyncio.create_task(solver.text('What is 2+2?'))
599
+ task3 = asyncio.create_task(solver.text('Name of the planet we live on?'))
600
+
601
+ # Wait for all tasks to complete
602
+ results = await asyncio.gather(task1, task2, task3, return_exceptions=True)
603
+ return results
604
+
605
+ # This completes much faster than solving captchas sequentially
606
+ results = asyncio.run(solve_multiple_captchas())
607
+ ```
608
+
609
+ Examples of solving all supported captcha types asynchronously are located in the [examples/async directory] directory.
610
+
611
+ ### Legacy Async Method
612
+
613
+ For backward compatibility, you can also use the traditional executor-based approach with the synchronous client:
555
614
 
556
615
  ```python
557
616
  import asyncio
@@ -569,11 +628,12 @@ async def captchaSolver(image):
569
628
 
570
629
  captcha_result = asyncio.run(captchaSolver(image))
571
630
  ```
631
+
572
632
  ## Examples
573
633
  Examples of solving all supported captcha types are located in the [examples] directory.
574
634
 
575
635
  ## Examples using Selenium
576
- Also we have a [separate repository](https://github.com/2captcha/captcha-solver-selenium-python-examples) you can find examples of captcha solving using [Selenium](https://pypi.org/project/selenium/) library. At the moment we have implemented examples of bypassing [reCAPTCHA](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/reCAPTCHA), [hCaptcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/hCaptcha), [normal captcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/normal_captcha) (image captcha) and [text captcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/text_captcha) using Selenium.
636
+ Also we have a [separate repository](https://github.com/2captcha/captcha-solver-selenium-python-examples) you can find examples of captcha solving using [Selenium](https://pypi.org/project/selenium/) library. At the moment we have implemented examples of bypassing [reCAPTCHA](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/reCAPTCHA), [Cloudflare](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/cloudflare), [Coordinates](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/coordinates), [MTCaptcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/mtcaptcha), [normal captcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/normal_captcha) (image captcha) and [text captcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/text_captcha) using Selenium.
577
637
 
578
638
  ## Useful articles
579
639
 
@@ -608,6 +668,8 @@ The graphics and trademarks included in this repository are not covered by the M
608
668
  [post options]: https://2captcha.com/2captcha-api#normal_post
609
669
  [list of supported languages]: https://2captcha.com/2captcha-api#language
610
670
  [examples directory]: /examples
671
+ [examples/sync directory]: /examples/sync
672
+ [examples/async directory]: /examples/async
611
673
  [asyncio]: https://docs.python.org/3/library/asyncio.html
612
674
  [Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
613
675
  [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
@@ -0,0 +1,16 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ 2captcha_python.egg-info/PKG-INFO
5
+ 2captcha_python.egg-info/SOURCES.txt
6
+ 2captcha_python.egg-info/dependency_links.txt
7
+ 2captcha_python.egg-info/requires.txt
8
+ 2captcha_python.egg-info/top_level.txt
9
+ twocaptcha/__init__.py
10
+ twocaptcha/api.py
11
+ twocaptcha/async_api.py
12
+ twocaptcha/async_solver.py
13
+ twocaptcha/solver.py
14
+ twocaptcha/exceptions/__init__.py
15
+ twocaptcha/exceptions/api.py
16
+ twocaptcha/exceptions/solver.py
@@ -0,0 +1,3 @@
1
+ requests
2
+ httpx
3
+ aiofiles
@@ -1,3 +1,36 @@
1
+ Metadata-Version: 2.4
2
+ Name: 2captcha-python
3
+ Version: 2.0.0
4
+ Summary: Python module for easy integration with 2Captcha API
5
+ Home-page: https://github.com/2captcha/2captcha-python/
6
+ Author: 2Captcha
7
+ Author-email: info@2captcha.com
8
+ Keywords: 2captcha,captcha,api,captcha solver,reCAPTCHA,FunCaptcha,Geetest,image captcha,Coordinates,Click Captcha,Geetest V4,Lemin captcha,Amazon WAF,Cloudflare Turnstile,Capy Puzzle,MTCaptcha,Friendly Captcha,Tencent,Cutcaptcha,DataDome,cybersiara
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
14
+ Classifier: Topic :: Utilities
15
+ Classifier: Intended Audience :: Developers
16
+ Requires-Python: >=3.6
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: requests
20
+ Requires-Dist: httpx
21
+ Requires-Dist: aiofiles
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: keywords
29
+ Dynamic: license-file
30
+ Dynamic: requires-dist
31
+ Dynamic: requires-python
32
+ Dynamic: summary
33
+
1
34
  <a href="https://github.com/2captcha/2captcha-python"><img src="https://github.com/user-attachments/assets/a737d428-5233-4605-9d09-211fa213d069" width="82" height="30"></a>
2
35
  <a href="https://github.com/2captcha/2captcha-javascript"><img src="https://github.com/user-attachments/assets/4d3b4541-34b2-4ed2-a687-d694ce67e5a6" width="36" height="30"></a>
3
36
  <a href="https://github.com/2captcha/2captcha-go"><img src="https://github.com/user-attachments/assets/ab22182e-6cb2-41fa-91f4-d5e89c6d7c6f" width="63" height="30"></a>
@@ -26,7 +59,7 @@ Examples of API requests for different captcha types are available on the [Pytho
26
59
  - [FunCaptcha](#funcaptcha)
27
60
  - [GeeTest](#geetest)
28
61
  - [GeeTest v4](#geetest-v4)
29
- - [hCaptcha](#hcaptcha)
62
+ - [Yandex Smart](#yandex-smart)
30
63
  - [Lemin Cropped Captcha](#lemin-cropped-captcha)
31
64
  - [Cloudflare Turnstile](#cloudflare-turnstile)
32
65
  - [Amazon WAF](#amazon-waf)
@@ -41,7 +74,7 @@ Examples of API requests for different captcha types are available on the [Pytho
41
74
  - [Friendly Captcha](#friendly-captcha)
42
75
  - [Cutcaptcha](#cutcaptcha)
43
76
  - [Tencent](#tencent)
44
- - [Datadome](#datadome)
77
+ - [DataDome](#datadome)
45
78
  - [CyberSiARA](#cybersiara)
46
79
  - [Other methods](#other-methods)
47
80
  - [send / get\_result](#send--get_result)
@@ -52,11 +85,11 @@ Examples of API requests for different captcha types are available on the [Pytho
52
85
  - [Async calls](#async-calls)
53
86
  - [Examples](#examples)
54
87
  - [Examples using Selenium](#examples-using-selenium)
55
- - [Useful articles](#useful-articles)
56
- - [Get in touch](#get-in-touch)
57
- - [Join the team 👪](#join-the-team-)
58
- - [License](#license)
59
- - [Graphics and Trademarks](#graphics-and-trademarks)
88
+ - [Useful articles](#useful-articles)
89
+ - [Get in touch](#get-in-touch)
90
+ - [Join the team 👪](#join-the-team-)
91
+ - [License](#license)
92
+ - [Graphics and Trademarks](#graphics-and-trademarks)
60
93
 
61
94
  ## Installation
62
95
 
@@ -76,6 +109,18 @@ from twocaptcha import TwoCaptcha
76
109
 
77
110
  solver = TwoCaptcha('YOUR_API_KEY')
78
111
  ```
112
+
113
+ <details>
114
+ <summary>Async</summary>
115
+
116
+ ```python
117
+ from twocaptcha import AsyncTwoCaptcha
118
+
119
+ solver = AsyncTwoCaptcha('YOUR_API_KEY')
120
+ ```
121
+
122
+ </details>
123
+
79
124
  Also, there are a few options that can be configured:
80
125
 
81
126
  ```python
@@ -87,6 +132,7 @@ config = {
87
132
  'defaultTimeout': 120,
88
133
  'recaptchaTimeout': 600,
89
134
  'pollingInterval': 10,
135
+ 'extendedResponse': False
90
136
  }
91
137
  solver = TwoCaptcha(**config)
92
138
  ```
@@ -101,7 +147,7 @@ solver = TwoCaptcha(**config)
101
147
  | 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 |
102
148
  | recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from the `res.php` API endpoint |
103
149
  | pollingInterval | 10 | Interval in seconds between requests to the `res.php` API endpoint. Setting values less than 5 seconds is not recommended |
104
- | 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 [hCaptcha](#hcaptcha), [ClickCaptcha](#clickcaptcha), [Canvas](#canvas) |
150
+ | 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](#clickcaptcha), [Canvas](#canvas) |
105
151
 
106
152
 
107
153
  > [!IMPORTANT]
@@ -225,19 +271,6 @@ result = solver.geetest_v4(captcha_id='e392e1d7fd421dc63325744d5a2b9c73',
225
271
  ```
226
272
 
227
273
 
228
- ### hCaptcha
229
-
230
- <sup>[API method description.](https://2captcha.com/2captcha-api#solving_hcaptcha)</sup>
231
-
232
- Use this method to solve the hCaptcha challenge. Returns a token to bypass the captcha.
233
- ```python
234
- result = solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001',
235
- url='https://www.site.com/page/',
236
- param1=..., ...)
237
-
238
- ```
239
-
240
-
241
274
  ### Lemin Cropped Captcha
242
275
 
243
276
  <sup>[API method description.](https://2captcha.com/2captcha-api#lemin)</sup>
@@ -251,6 +284,15 @@ result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d90
251
284
 
252
285
  ```
253
286
 
287
+ ### Yandex Smart
288
+
289
+ Use this method to solve Yandex Smart Captcha. Returns JSON with the token.
290
+ ```python
291
+ result = solver.yandex_smart(sitekey='0x1AAAAh45AAAAkg0s2VIOD34y5hy4h4h',
292
+ url='http://mysite.com/',
293
+ proxy={'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'},
294
+ 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')
295
+ ```
254
296
 
255
297
  ### Cloudflare Turnstile
256
298
 
@@ -404,7 +446,7 @@ result = solver.cutcaptcha(misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320'
404
446
 
405
447
  <sup>[API method description.](https://2captcha.com/2captcha-api#tencent)</sup>
406
448
 
407
- Use this method to solve Cutcaptcha. Returns a token.
449
+ Use this method to solve Tencent captcha. Returns a token.
408
450
  ```python
409
451
  result = solver.tencent(app_id="197326679",
410
452
  url="https://mysite.com/page/with/tencent",
@@ -447,7 +489,7 @@ result = solver.cybersiara(master_url_id='tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv',
447
489
 
448
490
  ### send / get_result
449
491
  These methods can be used for manual captcha submission and answer polling. The `send()` method supports sending any captcha
450
- type, to specify the captcha type you must send value `method` manually, for example `method='hcaptcha'` for solving hCapthca.
492
+ type, to specify the captcha type you must send value `method` manually, for example `method='recaptcha'` for solving reCaptcha.
451
493
  You can find the value of the `method` parameter in the [API documentation](https://2captcha.com/2captcha-api).
452
494
 
453
495
  Example for solving Normal captcha manually:
@@ -459,17 +501,6 @@ import time
459
501
  id = solver.send(file='path/to/captcha.jpg')
460
502
  time.sleep(20)
461
503
 
462
- code = solver.get_result(id)
463
- ```
464
- Example for solving hCaptcha manually:
465
- ```python
466
- import time
467
- . . . . .
468
- id = solver.send(sitekey='41b778e7-8f20-45cc-a804-1f1ebb45c579',
469
- url='https://2captcha.com/demo/hcaptcha?difficulty=easy',
470
- method='hcaptcha')
471
- print(id)
472
- time.sleep(20)
473
504
  code = solver.get_result(id)
474
505
  ```
475
506
 
@@ -515,7 +546,7 @@ except TimeoutException as e:
515
546
 
516
547
  ## Proxies
517
548
 
518
- You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha,
549
+ You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4,
519
550
  keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha, Tencent, DataDome, cybersiara.
520
551
 
521
552
 
@@ -531,7 +562,55 @@ proxy={
531
562
  ```
532
563
 
533
564
  ## Async calls
534
- You can also make async calls with [asyncio], for example:
565
+
566
+ To use the async version, just replace `TwoCaptcha` with `AsyncTwoCaptcha`:
567
+
568
+ ```python
569
+ import asyncio
570
+ from twocaptcha import AsyncTwoCaptcha
571
+
572
+ async def solve_captcha():
573
+ solver = AsyncTwoCaptcha('YOUR_API_KEY')
574
+
575
+ try:
576
+ recaptcha_result = await solver.recaptcha(...)
577
+ return recaptcha_result
578
+ except Exception as e:
579
+ print(e)
580
+ return None
581
+
582
+ if __name__ == '__main__':
583
+ result = asyncio.run(solve_captcha())
584
+ ```
585
+
586
+ The `AsyncTwoCaptcha` class supports all the same methods and parameters as the synchronous `TwoCaptcha` class but operates asynchronously. Configuration is identical.
587
+
588
+ ### Solving Multiple Captchas in Parallel
589
+
590
+ One of the main advantages of using async support is the ability to solve multiple captchas concurrently:
591
+
592
+ ```python
593
+ async def solve_multiple_captchas():
594
+ solver = AsyncTwoCaptcha('YOUR_API_KEY')
595
+
596
+ # Start all tasks simultaneously
597
+ task1 = asyncio.create_task(solver.text('What color is the sky on a clear day?'))
598
+ task2 = asyncio.create_task(solver.text('What is 2+2?'))
599
+ task3 = asyncio.create_task(solver.text('Name of the planet we live on?'))
600
+
601
+ # Wait for all tasks to complete
602
+ results = await asyncio.gather(task1, task2, task3, return_exceptions=True)
603
+ return results
604
+
605
+ # This completes much faster than solving captchas sequentially
606
+ results = asyncio.run(solve_multiple_captchas())
607
+ ```
608
+
609
+ Examples of solving all supported captcha types asynchronously are located in the [examples/async directory] directory.
610
+
611
+ ### Legacy Async Method
612
+
613
+ For backward compatibility, you can also use the traditional executor-based approach with the synchronous client:
535
614
 
536
615
  ```python
537
616
  import asyncio
@@ -549,11 +628,12 @@ async def captchaSolver(image):
549
628
 
550
629
  captcha_result = asyncio.run(captchaSolver(image))
551
630
  ```
631
+
552
632
  ## Examples
553
633
  Examples of solving all supported captcha types are located in the [examples] directory.
554
634
 
555
635
  ## Examples using Selenium
556
- Also we have a [separate repository](https://github.com/2captcha/captcha-solver-selenium-python-examples) you can find examples of captcha solving using [Selenium](https://pypi.org/project/selenium/) library. At the moment we have implemented examples of bypassing [reCAPTCHA](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/reCAPTCHA), [hCaptcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/hCaptcha), [normal captcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/normal_captcha) (image captcha) and [text captcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/text_captcha) using Selenium.
636
+ Also we have a [separate repository](https://github.com/2captcha/captcha-solver-selenium-python-examples) you can find examples of captcha solving using [Selenium](https://pypi.org/project/selenium/) library. At the moment we have implemented examples of bypassing [reCAPTCHA](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/reCAPTCHA), [Cloudflare](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/cloudflare), [Coordinates](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/coordinates), [MTCaptcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/mtcaptcha), [normal captcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/normal_captcha) (image captcha) and [text captcha](https://github.com/2captcha/captcha-solver-selenium-python-examples/tree/main/examples/text_captcha) using Selenium.
557
637
 
558
638
  ## Useful articles
559
639
 
@@ -588,8 +668,10 @@ The graphics and trademarks included in this repository are not covered by the M
588
668
  [post options]: https://2captcha.com/2captcha-api#normal_post
589
669
  [list of supported languages]: https://2captcha.com/2captcha-api#language
590
670
  [examples directory]: /examples
671
+ [examples/sync directory]: /examples/sync
672
+ [examples/async directory]: /examples/async
591
673
  [asyncio]: https://docs.python.org/3/library/asyncio.html
592
674
  [Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
593
675
  [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
594
676
  [examples]: ./examples
595
- [residential proxies]: https://2captcha.com/proxy/residential-proxies
677
+ [residential proxies]: https://2captcha.com/proxy/residential-proxies