2captcha-python 1.2.7__tar.gz → 1.3.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.
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0/2captcha_python.egg-info}/PKG-INFO +108 -22
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/2captcha_python.egg-info/SOURCES.txt +1 -0
- 2captcha_python-1.2.7/README.md → 2captcha_python-1.3.0/PKG-INFO +123 -22
- 2captcha_python-1.2.7/2captcha_python.egg-info/PKG-INFO → 2captcha_python-1.3.0/README.md +103 -37
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/setup.py +9 -0
- 2captcha_python-1.3.0/tests/test_datadome.py +34 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/twocaptcha/__init__.py +1 -1
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/twocaptcha/solver.py +24 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/2captcha_python.egg-info/dependency_links.txt +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/2captcha_python.egg-info/requires.txt +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/2captcha_python.egg-info/top_level.txt +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/LICENSE +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/setup.cfg +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_amazon_waf.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_atb_captcha.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_canvas.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_capy.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_coordinates.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_cutcaptcha.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_friendly_captcha.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_funcaptcha.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_geetest.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_geetest_v4.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_grid.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_hcaptcha.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_keycaptcha.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_lemin.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_mtcaptcha.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_normal.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_recaptcha.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_rotate.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_tencent.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_text.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/tests/test_turnstile.py +0 -0
- {2captcha_python-1.2.7 → 2captcha_python-1.3.0}/twocaptcha/api.py +0 -0
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: 2captcha-python
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.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
|
|
8
9
|
Classifier: Programming Language :: Python :: 3
|
|
9
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
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
|
|
11
16
|
Requires-Python: >=3.6
|
|
12
17
|
Description-Content-Type: text/markdown
|
|
13
18
|
License-File: LICENSE
|
|
14
19
|
Requires-Dist: requests
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
<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
|
+
<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>
|
|
23
|
+
<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>
|
|
24
|
+
<a href="https://github.com/2captcha/2captcha-ruby"><img src="https://github.com/user-attachments/assets/0270d56f-79b0-4c95-9b09-4de89579914b" width="75" height="30"></a>
|
|
25
|
+
<a href="https://github.com/2captcha/2captcha-cpp"><img src="https://github.com/user-attachments/assets/36de8512-acfd-44fb-bb1f-b7c793a3f926" width="45" height="30"></a>
|
|
26
|
+
<a href="https://github.com/2captcha/2captcha-php"><img src="https://github.com/user-attachments/assets/e8797843-3f61-4fa9-a155-ab0b21fb3858" width="52" height="30"></a>
|
|
27
|
+
<a href="https://github.com/2captcha/2captcha-java"><img src="https://github.com/user-attachments/assets/a3d923f6-4fec-4c07-ac50-e20da6370911" width="50" height="30"></a>
|
|
28
|
+
<a href="https://github.com/2captcha/2captcha-csharp"><img src="https://github.com/user-attachments/assets/f4d449de-780b-49ed-bb0a-b70c82ec4b32" width="38" height="30"></a>
|
|
18
29
|
|
|
19
|
-
|
|
30
|
+
# Python Module for 2Captcha API (captcha solver)
|
|
31
|
+
|
|
32
|
+
The easiest way to quickly integrate the [2Captcha] captcha-solving service into your code and automate the solving of any type of captcha.
|
|
33
|
+
Examples of API requests for different captcha types are available on the [Python captcha solver](https://2captcha.com/lang/python) page.
|
|
34
|
+
|
|
35
|
+
- [Python Module for 2Captcha API (captcha solver)](#python-module-for-2captcha-api-captcha-solver)
|
|
20
36
|
- [Installation](#installation)
|
|
21
37
|
- [Configuration](#configuration)
|
|
22
38
|
- [TwoCaptcha instance options](#twocaptcha-instance-options)
|
|
@@ -29,8 +45,8 @@ The easiest way to quickly integrate the 2Captcha captcha-solving service into y
|
|
|
29
45
|
- [reCAPTCHA v3](#recaptcha-v3)
|
|
30
46
|
- [FunCaptcha](#funcaptcha)
|
|
31
47
|
- [GeeTest](#geetest)
|
|
32
|
-
- [hCaptcha](#hcaptcha)
|
|
33
48
|
- [GeeTest v4](#geetest-v4)
|
|
49
|
+
- [hCaptcha](#hcaptcha)
|
|
34
50
|
- [Lemin Cropped Captcha](#lemin-cropped-captcha)
|
|
35
51
|
- [Cloudflare Turnstile](#cloudflare-turnstile)
|
|
36
52
|
- [Amazon WAF](#amazon-waf)
|
|
@@ -45,14 +61,21 @@ The easiest way to quickly integrate the 2Captcha captcha-solving service into y
|
|
|
45
61
|
- [Friendly Captcha](#friendly-captcha)
|
|
46
62
|
- [Cutcaptcha](#cutcaptcha)
|
|
47
63
|
- [Tencent](#tencent)
|
|
64
|
+
- [Datadome](#datadome)
|
|
48
65
|
- [Other methods](#other-methods)
|
|
49
66
|
- [send / get_result](#send--get_result)
|
|
50
67
|
- [balance](#balance)
|
|
51
68
|
- [report](#report)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
- [Error handling](#error-handling)
|
|
70
|
+
- [Proxies](#proxies)
|
|
71
|
+
- [Async calls](#async-calls)
|
|
55
72
|
- [Examples](#examples)
|
|
73
|
+
- [Examples using Selenium](#examples-using-selenium)
|
|
74
|
+
- [Useful articles](#useful-articles)
|
|
75
|
+
- [Get in touch](#get-in-touch)
|
|
76
|
+
- [Join the team 👪](#join-the-team-)
|
|
77
|
+
- [License](#license)
|
|
78
|
+
- [Graphics and Trademarks](#graphics-and-trademarks)
|
|
56
79
|
|
|
57
80
|
## Installation
|
|
58
81
|
|
|
@@ -89,16 +112,18 @@ solver = TwoCaptcha(**config)
|
|
|
89
112
|
|
|
90
113
|
### TwoCaptcha instance options
|
|
91
114
|
|
|
92
|
-
| Option | Default value | Description
|
|
93
|
-
| ---------------- | --------------
|
|
94
|
-
| server | `2captcha.com` | API server. You can set it to `rucaptcha.com` if your account is registered there
|
|
95
|
-
| softId |
|
|
96
|
-
| callback | - | URL of your web server that receives the captcha recognition result. The URL should be first registered in [pingback settings] of your account
|
|
115
|
+
| Option | Default value | Description |
|
|
116
|
+
| ---------------- | -------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
117
|
+
| server | `2captcha.com` | API server. You can set it to `rucaptcha.com` if your account is registered there |
|
|
118
|
+
| softId | 4580 | your software ID obtained after publishing in [2captcha software catalog] |
|
|
119
|
+
| callback | - | URL of your web server that receives the captcha recognition result. The URL should be first registered in [pingback settings] of your account |
|
|
97
120
|
| 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 |
|
|
98
121
|
| recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from the `res.php` API endpoint |
|
|
99
122
|
| pollingInterval | 10 | Interval in seconds between requests to the `res.php` API endpoint. Setting values less than 5 seconds is not recommended |
|
|
100
123
|
|
|
101
|
-
>
|
|
124
|
+
> [!IMPORTANT]
|
|
125
|
+
> Once `callback` is defined for the `TwoCaptcha` instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL.
|
|
126
|
+
|
|
102
127
|
To get the answer manually use [get_result method](#send--get_result)
|
|
103
128
|
|
|
104
129
|
## Solve captcha
|
|
@@ -234,7 +259,7 @@ result = solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001',
|
|
|
234
259
|
|
|
235
260
|
<sup>[API method description.](https://2captcha.com/2captcha-api#lemin)</sup>
|
|
236
261
|
|
|
237
|
-
Use this method to solve
|
|
262
|
+
Use this method to solve the Lemin captcha. Returns JSON with an answer containing the following values: answer, challenge_id.
|
|
238
263
|
```python
|
|
239
264
|
result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d',
|
|
240
265
|
div_id='lemin-cropped-captcha',
|
|
@@ -370,6 +395,10 @@ result = solver.mtcaptcha(sitekey='MTPublic-KzqLY1cKH',
|
|
|
370
395
|
<sup>[API method description.](https://2captcha.com/2captcha-api#friendly-captcha)</sup>
|
|
371
396
|
|
|
372
397
|
Friendly Captcha solving method. Returns a token.
|
|
398
|
+
|
|
399
|
+
> [!IMPORTANT]
|
|
400
|
+
> To successfully use the received token, the captcha widget must not be loaded on the page. To do this, you need to abort request to `/friendlycaptcha/...module.min.js` on the page. When the captcha widget is already loaded on the page, there is a high probability that the received token will not work.
|
|
401
|
+
|
|
373
402
|
```python
|
|
374
403
|
result = solver.friendly_captcha(sitekey='FCMGEMUD2KTDSQ5H',
|
|
375
404
|
url='https://friendlycaptcha.com/demo',
|
|
@@ -399,6 +428,26 @@ result = solver.tencent(app_id="197326679",
|
|
|
399
428
|
param1=..., ...)
|
|
400
429
|
```
|
|
401
430
|
|
|
431
|
+
### DataDome
|
|
432
|
+
|
|
433
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#datadome)</sup>
|
|
434
|
+
|
|
435
|
+
Use this method to solve DataDome captcha.
|
|
436
|
+
|
|
437
|
+
> [!IMPORTANT]
|
|
438
|
+
> To solve the DataDome captcha, you must use a proxy. It is recommended to use [residential proxies].
|
|
439
|
+
|
|
440
|
+
```python
|
|
441
|
+
result = solver.datadome(captcha_url="https://geo.captcha-delivery.com/captcha/?initialCid=...",
|
|
442
|
+
pageurl="https://mysite.com/page/with/datadome",
|
|
443
|
+
userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
|
444
|
+
proxy={
|
|
445
|
+
'type': 'HTTP',
|
|
446
|
+
'uri': 'login:password@IP_address:PORT'
|
|
447
|
+
},
|
|
448
|
+
param1=..., ...)
|
|
449
|
+
```
|
|
450
|
+
|
|
402
451
|
## Other methods
|
|
403
452
|
|
|
404
453
|
### send / get_result
|
|
@@ -430,20 +479,27 @@ code = solver.get_result(id)
|
|
|
430
479
|
```
|
|
431
480
|
|
|
432
481
|
### balance
|
|
482
|
+
|
|
483
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#additional-methods)</sup>
|
|
484
|
+
|
|
433
485
|
Use this method to get your account's balance
|
|
434
486
|
```python
|
|
435
487
|
balance = solver.balance()
|
|
436
488
|
```
|
|
437
489
|
|
|
438
490
|
### report
|
|
491
|
+
|
|
492
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#complain)</sup>
|
|
493
|
+
|
|
439
494
|
Use this method to report good or bad captcha answers.
|
|
440
495
|
```python
|
|
441
496
|
solver.report(id, True) # captcha solved correctly
|
|
442
497
|
solver.report(id, False) # captcha solved incorrectly
|
|
443
498
|
```
|
|
444
499
|
|
|
445
|
-
|
|
446
|
-
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.
|
|
500
|
+
## Error handling
|
|
501
|
+
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.
|
|
502
|
+
The list of all errors can be found in the [API documentation](https://2captcha.com/2captcha-api#list-of-inphp-errors).
|
|
447
503
|
```python
|
|
448
504
|
try:
|
|
449
505
|
result = solver.text('If tomorrow is Saturday, what day is today?')
|
|
@@ -462,10 +518,10 @@ except TimeoutException as e:
|
|
|
462
518
|
```
|
|
463
519
|
|
|
464
520
|
|
|
465
|
-
|
|
521
|
+
## Proxies
|
|
466
522
|
|
|
467
523
|
You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha,
|
|
468
|
-
keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha.
|
|
524
|
+
keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha, Tencent, DataDome.
|
|
469
525
|
|
|
470
526
|
The proxy will be forwarded to the API to solve the captcha.
|
|
471
527
|
|
|
@@ -478,7 +534,7 @@ proxy={
|
|
|
478
534
|
}
|
|
479
535
|
```
|
|
480
536
|
|
|
481
|
-
|
|
537
|
+
## Async calls
|
|
482
538
|
You can also make async calls with [asyncio], for example:
|
|
483
539
|
|
|
484
540
|
```python
|
|
@@ -500,9 +556,38 @@ captcha_result = asyncio.run(captchaSolver(image))
|
|
|
500
556
|
## Examples
|
|
501
557
|
Examples of solving all supported captcha types are located in the [examples] directory.
|
|
502
558
|
|
|
503
|
-
|
|
559
|
+
## Examples using Selenium
|
|
560
|
+
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.
|
|
561
|
+
|
|
562
|
+
## Useful articles
|
|
563
|
+
|
|
564
|
+
- Amazon captcha solver: Code example for bypassing the [Amazon captcha](https://2captcha.com/blog/amazon-captcha-solving)
|
|
565
|
+
- [Captcha bypass in Selenium](https://2captcha.com/blog/captcha-bypass-in-selenium)
|
|
566
|
+
|
|
567
|
+
## Get in touch
|
|
568
|
+
|
|
569
|
+
<a href="mailto:support@2captcha.com"><img src="https://github.com/user-attachments/assets/539df209-7c85-4fa5-84b4-fc22ab93fac7" width="80" height="30"></a>
|
|
570
|
+
<a href="https://2captcha.com/support/tickets/new"><img src="https://github.com/user-attachments/assets/be044db5-2e67-46c6-8c81-04b78bd99650" width="81" height="30"></a>
|
|
571
|
+
|
|
572
|
+
## Join the team 👪
|
|
573
|
+
|
|
574
|
+
There are many ways to contribute, of which development is only one! Find your next job. Open positions: AI experts, scrapers, developers, technical support, and much more! 😍
|
|
575
|
+
|
|
576
|
+
<a href="mailto:job@2captcha.com"><img src="https://github.com/user-attachments/assets/36d23ef5-7866-4841-8e17-261cc8a4e033" width="80" height="30"></a>
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
## License
|
|
580
|
+
|
|
581
|
+
The code in this repository is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
|
|
582
|
+
|
|
583
|
+
### Graphics and Trademarks
|
|
584
|
+
|
|
585
|
+
The graphics and trademarks included in this repository are not covered by the MIT License. Please contact <a href="mailto:support@2captcha.com">support</a> for permissions regarding the use of these materials.
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
<!-- Shared links for README.md -->
|
|
504
589
|
[2Captcha]: https://2captcha.com/
|
|
505
|
-
[2captcha
|
|
590
|
+
[2captcha software catalog]: https://2captcha.com/software
|
|
506
591
|
[pingback settings]: https://2captcha.com/setting/pingback
|
|
507
592
|
[post options]: https://2captcha.com/2captcha-api#normal_post
|
|
508
593
|
[list of supported languages]: https://2captcha.com/2captcha-api#language
|
|
@@ -511,3 +596,4 @@ Examples of solving all supported captcha types are located in the [examples] di
|
|
|
511
596
|
[Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
|
|
512
597
|
[Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
|
|
513
598
|
[examples]: ./examples
|
|
599
|
+
[residential proxies]: https://2captcha.com/proxy/residential-proxies
|
|
@@ -1,7 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: 2captcha-python
|
|
3
|
+
Version: 1.3.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,hCaptcha,FunCaptcha,Geetest,image captcha,Coordinates,Click Captcha,Geetest V4,Lemin captcha,Amazon WAF,Cloudflare Turnstile,Capy Puzzle,MTCaptcha,Friendly Captcha,Tencent,Cutcaptcha,DataDome
|
|
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
|
+
|
|
21
|
+
<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
|
+
<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>
|
|
23
|
+
<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>
|
|
24
|
+
<a href="https://github.com/2captcha/2captcha-ruby"><img src="https://github.com/user-attachments/assets/0270d56f-79b0-4c95-9b09-4de89579914b" width="75" height="30"></a>
|
|
25
|
+
<a href="https://github.com/2captcha/2captcha-cpp"><img src="https://github.com/user-attachments/assets/36de8512-acfd-44fb-bb1f-b7c793a3f926" width="45" height="30"></a>
|
|
26
|
+
<a href="https://github.com/2captcha/2captcha-php"><img src="https://github.com/user-attachments/assets/e8797843-3f61-4fa9-a155-ab0b21fb3858" width="52" height="30"></a>
|
|
27
|
+
<a href="https://github.com/2captcha/2captcha-java"><img src="https://github.com/user-attachments/assets/a3d923f6-4fec-4c07-ac50-e20da6370911" width="50" height="30"></a>
|
|
28
|
+
<a href="https://github.com/2captcha/2captcha-csharp"><img src="https://github.com/user-attachments/assets/f4d449de-780b-49ed-bb0a-b70c82ec4b32" width="38" height="30"></a>
|
|
29
|
+
|
|
30
|
+
# Python Module for 2Captcha API (captcha solver)
|
|
31
|
+
|
|
32
|
+
The easiest way to quickly integrate the [2Captcha] captcha-solving service into your code and automate the solving of any type of captcha.
|
|
33
|
+
Examples of API requests for different captcha types are available on the [Python captcha solver](https://2captcha.com/lang/python) page.
|
|
34
|
+
|
|
35
|
+
- [Python Module for 2Captcha API (captcha solver)](#python-module-for-2captcha-api-captcha-solver)
|
|
5
36
|
- [Installation](#installation)
|
|
6
37
|
- [Configuration](#configuration)
|
|
7
38
|
- [TwoCaptcha instance options](#twocaptcha-instance-options)
|
|
@@ -14,8 +45,8 @@ The easiest way to quickly integrate the 2Captcha captcha-solving service into y
|
|
|
14
45
|
- [reCAPTCHA v3](#recaptcha-v3)
|
|
15
46
|
- [FunCaptcha](#funcaptcha)
|
|
16
47
|
- [GeeTest](#geetest)
|
|
17
|
-
- [hCaptcha](#hcaptcha)
|
|
18
48
|
- [GeeTest v4](#geetest-v4)
|
|
49
|
+
- [hCaptcha](#hcaptcha)
|
|
19
50
|
- [Lemin Cropped Captcha](#lemin-cropped-captcha)
|
|
20
51
|
- [Cloudflare Turnstile](#cloudflare-turnstile)
|
|
21
52
|
- [Amazon WAF](#amazon-waf)
|
|
@@ -30,14 +61,21 @@ The easiest way to quickly integrate the 2Captcha captcha-solving service into y
|
|
|
30
61
|
- [Friendly Captcha](#friendly-captcha)
|
|
31
62
|
- [Cutcaptcha](#cutcaptcha)
|
|
32
63
|
- [Tencent](#tencent)
|
|
64
|
+
- [Datadome](#datadome)
|
|
33
65
|
- [Other methods](#other-methods)
|
|
34
66
|
- [send / get_result](#send--get_result)
|
|
35
67
|
- [balance](#balance)
|
|
36
68
|
- [report](#report)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
69
|
+
- [Error handling](#error-handling)
|
|
70
|
+
- [Proxies](#proxies)
|
|
71
|
+
- [Async calls](#async-calls)
|
|
40
72
|
- [Examples](#examples)
|
|
73
|
+
- [Examples using Selenium](#examples-using-selenium)
|
|
74
|
+
- [Useful articles](#useful-articles)
|
|
75
|
+
- [Get in touch](#get-in-touch)
|
|
76
|
+
- [Join the team 👪](#join-the-team-)
|
|
77
|
+
- [License](#license)
|
|
78
|
+
- [Graphics and Trademarks](#graphics-and-trademarks)
|
|
41
79
|
|
|
42
80
|
## Installation
|
|
43
81
|
|
|
@@ -74,16 +112,18 @@ solver = TwoCaptcha(**config)
|
|
|
74
112
|
|
|
75
113
|
### TwoCaptcha instance options
|
|
76
114
|
|
|
77
|
-
| Option | Default value | Description
|
|
78
|
-
| ---------------- | --------------
|
|
79
|
-
| server | `2captcha.com` | API server. You can set it to `rucaptcha.com` if your account is registered there
|
|
80
|
-
| softId |
|
|
81
|
-
| callback | - | URL of your web server that receives the captcha recognition result. The URL should be first registered in [pingback settings] of your account
|
|
115
|
+
| Option | Default value | Description |
|
|
116
|
+
| ---------------- | -------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
117
|
+
| server | `2captcha.com` | API server. You can set it to `rucaptcha.com` if your account is registered there |
|
|
118
|
+
| softId | 4580 | your software ID obtained after publishing in [2captcha software catalog] |
|
|
119
|
+
| callback | - | URL of your web server that receives the captcha recognition result. The URL should be first registered in [pingback settings] of your account |
|
|
82
120
|
| 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 |
|
|
83
121
|
| recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from the `res.php` API endpoint |
|
|
84
122
|
| pollingInterval | 10 | Interval in seconds between requests to the `res.php` API endpoint. Setting values less than 5 seconds is not recommended |
|
|
85
123
|
|
|
86
|
-
>
|
|
124
|
+
> [!IMPORTANT]
|
|
125
|
+
> Once `callback` is defined for the `TwoCaptcha` instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL.
|
|
126
|
+
|
|
87
127
|
To get the answer manually use [get_result method](#send--get_result)
|
|
88
128
|
|
|
89
129
|
## Solve captcha
|
|
@@ -219,7 +259,7 @@ result = solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001',
|
|
|
219
259
|
|
|
220
260
|
<sup>[API method description.](https://2captcha.com/2captcha-api#lemin)</sup>
|
|
221
261
|
|
|
222
|
-
Use this method to solve
|
|
262
|
+
Use this method to solve the Lemin captcha. Returns JSON with an answer containing the following values: answer, challenge_id.
|
|
223
263
|
```python
|
|
224
264
|
result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d',
|
|
225
265
|
div_id='lemin-cropped-captcha',
|
|
@@ -355,6 +395,10 @@ result = solver.mtcaptcha(sitekey='MTPublic-KzqLY1cKH',
|
|
|
355
395
|
<sup>[API method description.](https://2captcha.com/2captcha-api#friendly-captcha)</sup>
|
|
356
396
|
|
|
357
397
|
Friendly Captcha solving method. Returns a token.
|
|
398
|
+
|
|
399
|
+
> [!IMPORTANT]
|
|
400
|
+
> To successfully use the received token, the captcha widget must not be loaded on the page. To do this, you need to abort request to `/friendlycaptcha/...module.min.js` on the page. When the captcha widget is already loaded on the page, there is a high probability that the received token will not work.
|
|
401
|
+
|
|
358
402
|
```python
|
|
359
403
|
result = solver.friendly_captcha(sitekey='FCMGEMUD2KTDSQ5H',
|
|
360
404
|
url='https://friendlycaptcha.com/demo',
|
|
@@ -384,6 +428,26 @@ result = solver.tencent(app_id="197326679",
|
|
|
384
428
|
param1=..., ...)
|
|
385
429
|
```
|
|
386
430
|
|
|
431
|
+
### DataDome
|
|
432
|
+
|
|
433
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#datadome)</sup>
|
|
434
|
+
|
|
435
|
+
Use this method to solve DataDome captcha.
|
|
436
|
+
|
|
437
|
+
> [!IMPORTANT]
|
|
438
|
+
> To solve the DataDome captcha, you must use a proxy. It is recommended to use [residential proxies].
|
|
439
|
+
|
|
440
|
+
```python
|
|
441
|
+
result = solver.datadome(captcha_url="https://geo.captcha-delivery.com/captcha/?initialCid=...",
|
|
442
|
+
pageurl="https://mysite.com/page/with/datadome",
|
|
443
|
+
userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
|
444
|
+
proxy={
|
|
445
|
+
'type': 'HTTP',
|
|
446
|
+
'uri': 'login:password@IP_address:PORT'
|
|
447
|
+
},
|
|
448
|
+
param1=..., ...)
|
|
449
|
+
```
|
|
450
|
+
|
|
387
451
|
## Other methods
|
|
388
452
|
|
|
389
453
|
### send / get_result
|
|
@@ -415,20 +479,27 @@ code = solver.get_result(id)
|
|
|
415
479
|
```
|
|
416
480
|
|
|
417
481
|
### balance
|
|
482
|
+
|
|
483
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#additional-methods)</sup>
|
|
484
|
+
|
|
418
485
|
Use this method to get your account's balance
|
|
419
486
|
```python
|
|
420
487
|
balance = solver.balance()
|
|
421
488
|
```
|
|
422
489
|
|
|
423
490
|
### report
|
|
491
|
+
|
|
492
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#complain)</sup>
|
|
493
|
+
|
|
424
494
|
Use this method to report good or bad captcha answers.
|
|
425
495
|
```python
|
|
426
496
|
solver.report(id, True) # captcha solved correctly
|
|
427
497
|
solver.report(id, False) # captcha solved incorrectly
|
|
428
498
|
```
|
|
429
499
|
|
|
430
|
-
|
|
431
|
-
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.
|
|
500
|
+
## Error handling
|
|
501
|
+
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.
|
|
502
|
+
The list of all errors can be found in the [API documentation](https://2captcha.com/2captcha-api#list-of-inphp-errors).
|
|
432
503
|
```python
|
|
433
504
|
try:
|
|
434
505
|
result = solver.text('If tomorrow is Saturday, what day is today?')
|
|
@@ -447,10 +518,10 @@ except TimeoutException as e:
|
|
|
447
518
|
```
|
|
448
519
|
|
|
449
520
|
|
|
450
|
-
|
|
521
|
+
## Proxies
|
|
451
522
|
|
|
452
523
|
You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha,
|
|
453
|
-
keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha.
|
|
524
|
+
keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha, Tencent, DataDome.
|
|
454
525
|
|
|
455
526
|
The proxy will be forwarded to the API to solve the captcha.
|
|
456
527
|
|
|
@@ -463,7 +534,7 @@ proxy={
|
|
|
463
534
|
}
|
|
464
535
|
```
|
|
465
536
|
|
|
466
|
-
|
|
537
|
+
## Async calls
|
|
467
538
|
You can also make async calls with [asyncio], for example:
|
|
468
539
|
|
|
469
540
|
```python
|
|
@@ -485,9 +556,38 @@ captcha_result = asyncio.run(captchaSolver(image))
|
|
|
485
556
|
## Examples
|
|
486
557
|
Examples of solving all supported captcha types are located in the [examples] directory.
|
|
487
558
|
|
|
488
|
-
|
|
559
|
+
## Examples using Selenium
|
|
560
|
+
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.
|
|
561
|
+
|
|
562
|
+
## Useful articles
|
|
563
|
+
|
|
564
|
+
- Amazon captcha solver: Code example for bypassing the [Amazon captcha](https://2captcha.com/blog/amazon-captcha-solving)
|
|
565
|
+
- [Captcha bypass in Selenium](https://2captcha.com/blog/captcha-bypass-in-selenium)
|
|
566
|
+
|
|
567
|
+
## Get in touch
|
|
568
|
+
|
|
569
|
+
<a href="mailto:support@2captcha.com"><img src="https://github.com/user-attachments/assets/539df209-7c85-4fa5-84b4-fc22ab93fac7" width="80" height="30"></a>
|
|
570
|
+
<a href="https://2captcha.com/support/tickets/new"><img src="https://github.com/user-attachments/assets/be044db5-2e67-46c6-8c81-04b78bd99650" width="81" height="30"></a>
|
|
571
|
+
|
|
572
|
+
## Join the team 👪
|
|
573
|
+
|
|
574
|
+
There are many ways to contribute, of which development is only one! Find your next job. Open positions: AI experts, scrapers, developers, technical support, and much more! 😍
|
|
575
|
+
|
|
576
|
+
<a href="mailto:job@2captcha.com"><img src="https://github.com/user-attachments/assets/36d23ef5-7866-4841-8e17-261cc8a4e033" width="80" height="30"></a>
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
## License
|
|
580
|
+
|
|
581
|
+
The code in this repository is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
|
|
582
|
+
|
|
583
|
+
### Graphics and Trademarks
|
|
584
|
+
|
|
585
|
+
The graphics and trademarks included in this repository are not covered by the MIT License. Please contact <a href="mailto:support@2captcha.com">support</a> for permissions regarding the use of these materials.
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
<!-- Shared links for README.md -->
|
|
489
589
|
[2Captcha]: https://2captcha.com/
|
|
490
|
-
[2captcha
|
|
590
|
+
[2captcha software catalog]: https://2captcha.com/software
|
|
491
591
|
[pingback settings]: https://2captcha.com/setting/pingback
|
|
492
592
|
[post options]: https://2captcha.com/2captcha-api#normal_post
|
|
493
593
|
[list of supported languages]: https://2captcha.com/2captcha-api#language
|
|
@@ -496,3 +596,4 @@ Examples of solving all supported captcha types are located in the [examples] di
|
|
|
496
596
|
[Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
|
|
497
597
|
[Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
|
|
498
598
|
[examples]: ./examples
|
|
599
|
+
[residential proxies]: https://2captcha.com/proxy/residential-proxies
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# Python Module for 2Captcha API
|
|
17
|
-
The easiest way to quickly integrate the 2Captcha captcha-solving service into your code and automate the solving of any type of captcha.
|
|
18
|
-
|
|
19
|
-
- [Python Module for 2Captcha API](#python-module-for-2captcha-api)
|
|
1
|
+
<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
|
+
<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
|
+
<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>
|
|
4
|
+
<a href="https://github.com/2captcha/2captcha-ruby"><img src="https://github.com/user-attachments/assets/0270d56f-79b0-4c95-9b09-4de89579914b" width="75" height="30"></a>
|
|
5
|
+
<a href="https://github.com/2captcha/2captcha-cpp"><img src="https://github.com/user-attachments/assets/36de8512-acfd-44fb-bb1f-b7c793a3f926" width="45" height="30"></a>
|
|
6
|
+
<a href="https://github.com/2captcha/2captcha-php"><img src="https://github.com/user-attachments/assets/e8797843-3f61-4fa9-a155-ab0b21fb3858" width="52" height="30"></a>
|
|
7
|
+
<a href="https://github.com/2captcha/2captcha-java"><img src="https://github.com/user-attachments/assets/a3d923f6-4fec-4c07-ac50-e20da6370911" width="50" height="30"></a>
|
|
8
|
+
<a href="https://github.com/2captcha/2captcha-csharp"><img src="https://github.com/user-attachments/assets/f4d449de-780b-49ed-bb0a-b70c82ec4b32" width="38" height="30"></a>
|
|
9
|
+
|
|
10
|
+
# Python Module for 2Captcha API (captcha solver)
|
|
11
|
+
|
|
12
|
+
The easiest way to quickly integrate the [2Captcha] captcha-solving service into your code and automate the solving of any type of captcha.
|
|
13
|
+
Examples of API requests for different captcha types are available on the [Python captcha solver](https://2captcha.com/lang/python) page.
|
|
14
|
+
|
|
15
|
+
- [Python Module for 2Captcha API (captcha solver)](#python-module-for-2captcha-api-captcha-solver)
|
|
20
16
|
- [Installation](#installation)
|
|
21
17
|
- [Configuration](#configuration)
|
|
22
18
|
- [TwoCaptcha instance options](#twocaptcha-instance-options)
|
|
@@ -29,8 +25,8 @@ The easiest way to quickly integrate the 2Captcha captcha-solving service into y
|
|
|
29
25
|
- [reCAPTCHA v3](#recaptcha-v3)
|
|
30
26
|
- [FunCaptcha](#funcaptcha)
|
|
31
27
|
- [GeeTest](#geetest)
|
|
32
|
-
- [hCaptcha](#hcaptcha)
|
|
33
28
|
- [GeeTest v4](#geetest-v4)
|
|
29
|
+
- [hCaptcha](#hcaptcha)
|
|
34
30
|
- [Lemin Cropped Captcha](#lemin-cropped-captcha)
|
|
35
31
|
- [Cloudflare Turnstile](#cloudflare-turnstile)
|
|
36
32
|
- [Amazon WAF](#amazon-waf)
|
|
@@ -45,14 +41,21 @@ The easiest way to quickly integrate the 2Captcha captcha-solving service into y
|
|
|
45
41
|
- [Friendly Captcha](#friendly-captcha)
|
|
46
42
|
- [Cutcaptcha](#cutcaptcha)
|
|
47
43
|
- [Tencent](#tencent)
|
|
44
|
+
- [Datadome](#datadome)
|
|
48
45
|
- [Other methods](#other-methods)
|
|
49
46
|
- [send / get_result](#send--get_result)
|
|
50
47
|
- [balance](#balance)
|
|
51
48
|
- [report](#report)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
- [Error handling](#error-handling)
|
|
50
|
+
- [Proxies](#proxies)
|
|
51
|
+
- [Async calls](#async-calls)
|
|
55
52
|
- [Examples](#examples)
|
|
53
|
+
- [Examples using Selenium](#examples-using-selenium)
|
|
54
|
+
- [Useful articles](#useful-articles)
|
|
55
|
+
- [Get in touch](#get-in-touch)
|
|
56
|
+
- [Join the team 👪](#join-the-team-)
|
|
57
|
+
- [License](#license)
|
|
58
|
+
- [Graphics and Trademarks](#graphics-and-trademarks)
|
|
56
59
|
|
|
57
60
|
## Installation
|
|
58
61
|
|
|
@@ -89,16 +92,18 @@ solver = TwoCaptcha(**config)
|
|
|
89
92
|
|
|
90
93
|
### TwoCaptcha instance options
|
|
91
94
|
|
|
92
|
-
| Option | Default value | Description
|
|
93
|
-
| ---------------- | --------------
|
|
94
|
-
| server | `2captcha.com` | API server. You can set it to `rucaptcha.com` if your account is registered there
|
|
95
|
-
| softId |
|
|
96
|
-
| callback | - | URL of your web server that receives the captcha recognition result. The URL should be first registered in [pingback settings] of your account
|
|
95
|
+
| Option | Default value | Description |
|
|
96
|
+
| ---------------- | -------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
97
|
+
| server | `2captcha.com` | API server. You can set it to `rucaptcha.com` if your account is registered there |
|
|
98
|
+
| softId | 4580 | your software ID obtained after publishing in [2captcha software catalog] |
|
|
99
|
+
| callback | - | URL of your web server that receives the captcha recognition result. The URL should be first registered in [pingback settings] of your account |
|
|
97
100
|
| 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 |
|
|
98
101
|
| recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from the `res.php` API endpoint |
|
|
99
102
|
| pollingInterval | 10 | Interval in seconds between requests to the `res.php` API endpoint. Setting values less than 5 seconds is not recommended |
|
|
100
103
|
|
|
101
|
-
>
|
|
104
|
+
> [!IMPORTANT]
|
|
105
|
+
> Once `callback` is defined for the `TwoCaptcha` instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL.
|
|
106
|
+
|
|
102
107
|
To get the answer manually use [get_result method](#send--get_result)
|
|
103
108
|
|
|
104
109
|
## Solve captcha
|
|
@@ -234,7 +239,7 @@ result = solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001',
|
|
|
234
239
|
|
|
235
240
|
<sup>[API method description.](https://2captcha.com/2captcha-api#lemin)</sup>
|
|
236
241
|
|
|
237
|
-
Use this method to solve
|
|
242
|
+
Use this method to solve the Lemin captcha. Returns JSON with an answer containing the following values: answer, challenge_id.
|
|
238
243
|
```python
|
|
239
244
|
result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d',
|
|
240
245
|
div_id='lemin-cropped-captcha',
|
|
@@ -370,6 +375,10 @@ result = solver.mtcaptcha(sitekey='MTPublic-KzqLY1cKH',
|
|
|
370
375
|
<sup>[API method description.](https://2captcha.com/2captcha-api#friendly-captcha)</sup>
|
|
371
376
|
|
|
372
377
|
Friendly Captcha solving method. Returns a token.
|
|
378
|
+
|
|
379
|
+
> [!IMPORTANT]
|
|
380
|
+
> To successfully use the received token, the captcha widget must not be loaded on the page. To do this, you need to abort request to `/friendlycaptcha/...module.min.js` on the page. When the captcha widget is already loaded on the page, there is a high probability that the received token will not work.
|
|
381
|
+
|
|
373
382
|
```python
|
|
374
383
|
result = solver.friendly_captcha(sitekey='FCMGEMUD2KTDSQ5H',
|
|
375
384
|
url='https://friendlycaptcha.com/demo',
|
|
@@ -399,6 +408,26 @@ result = solver.tencent(app_id="197326679",
|
|
|
399
408
|
param1=..., ...)
|
|
400
409
|
```
|
|
401
410
|
|
|
411
|
+
### DataDome
|
|
412
|
+
|
|
413
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#datadome)</sup>
|
|
414
|
+
|
|
415
|
+
Use this method to solve DataDome captcha.
|
|
416
|
+
|
|
417
|
+
> [!IMPORTANT]
|
|
418
|
+
> To solve the DataDome captcha, you must use a proxy. It is recommended to use [residential proxies].
|
|
419
|
+
|
|
420
|
+
```python
|
|
421
|
+
result = solver.datadome(captcha_url="https://geo.captcha-delivery.com/captcha/?initialCid=...",
|
|
422
|
+
pageurl="https://mysite.com/page/with/datadome",
|
|
423
|
+
userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
|
424
|
+
proxy={
|
|
425
|
+
'type': 'HTTP',
|
|
426
|
+
'uri': 'login:password@IP_address:PORT'
|
|
427
|
+
},
|
|
428
|
+
param1=..., ...)
|
|
429
|
+
```
|
|
430
|
+
|
|
402
431
|
## Other methods
|
|
403
432
|
|
|
404
433
|
### send / get_result
|
|
@@ -430,20 +459,27 @@ code = solver.get_result(id)
|
|
|
430
459
|
```
|
|
431
460
|
|
|
432
461
|
### balance
|
|
462
|
+
|
|
463
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#additional-methods)</sup>
|
|
464
|
+
|
|
433
465
|
Use this method to get your account's balance
|
|
434
466
|
```python
|
|
435
467
|
balance = solver.balance()
|
|
436
468
|
```
|
|
437
469
|
|
|
438
470
|
### report
|
|
471
|
+
|
|
472
|
+
<sup>[API method description.](https://2captcha.com/2captcha-api#complain)</sup>
|
|
473
|
+
|
|
439
474
|
Use this method to report good or bad captcha answers.
|
|
440
475
|
```python
|
|
441
476
|
solver.report(id, True) # captcha solved correctly
|
|
442
477
|
solver.report(id, False) # captcha solved incorrectly
|
|
443
478
|
```
|
|
444
479
|
|
|
445
|
-
|
|
446
|
-
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.
|
|
480
|
+
## Error handling
|
|
481
|
+
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.
|
|
482
|
+
The list of all errors can be found in the [API documentation](https://2captcha.com/2captcha-api#list-of-inphp-errors).
|
|
447
483
|
```python
|
|
448
484
|
try:
|
|
449
485
|
result = solver.text('If tomorrow is Saturday, what day is today?')
|
|
@@ -462,10 +498,10 @@ except TimeoutException as e:
|
|
|
462
498
|
```
|
|
463
499
|
|
|
464
500
|
|
|
465
|
-
|
|
501
|
+
## Proxies
|
|
466
502
|
|
|
467
503
|
You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha,
|
|
468
|
-
keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha.
|
|
504
|
+
keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha, Tencent, DataDome.
|
|
469
505
|
|
|
470
506
|
The proxy will be forwarded to the API to solve the captcha.
|
|
471
507
|
|
|
@@ -478,7 +514,7 @@ proxy={
|
|
|
478
514
|
}
|
|
479
515
|
```
|
|
480
516
|
|
|
481
|
-
|
|
517
|
+
## Async calls
|
|
482
518
|
You can also make async calls with [asyncio], for example:
|
|
483
519
|
|
|
484
520
|
```python
|
|
@@ -500,9 +536,38 @@ captcha_result = asyncio.run(captchaSolver(image))
|
|
|
500
536
|
## Examples
|
|
501
537
|
Examples of solving all supported captcha types are located in the [examples] directory.
|
|
502
538
|
|
|
503
|
-
|
|
539
|
+
## Examples using Selenium
|
|
540
|
+
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.
|
|
541
|
+
|
|
542
|
+
## Useful articles
|
|
543
|
+
|
|
544
|
+
- Amazon captcha solver: Code example for bypassing the [Amazon captcha](https://2captcha.com/blog/amazon-captcha-solving)
|
|
545
|
+
- [Captcha bypass in Selenium](https://2captcha.com/blog/captcha-bypass-in-selenium)
|
|
546
|
+
|
|
547
|
+
## Get in touch
|
|
548
|
+
|
|
549
|
+
<a href="mailto:support@2captcha.com"><img src="https://github.com/user-attachments/assets/539df209-7c85-4fa5-84b4-fc22ab93fac7" width="80" height="30"></a>
|
|
550
|
+
<a href="https://2captcha.com/support/tickets/new"><img src="https://github.com/user-attachments/assets/be044db5-2e67-46c6-8c81-04b78bd99650" width="81" height="30"></a>
|
|
551
|
+
|
|
552
|
+
## Join the team 👪
|
|
553
|
+
|
|
554
|
+
There are many ways to contribute, of which development is only one! Find your next job. Open positions: AI experts, scrapers, developers, technical support, and much more! 😍
|
|
555
|
+
|
|
556
|
+
<a href="mailto:job@2captcha.com"><img src="https://github.com/user-attachments/assets/36d23ef5-7866-4841-8e17-261cc8a4e033" width="80" height="30"></a>
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
## License
|
|
560
|
+
|
|
561
|
+
The code in this repository is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
|
|
562
|
+
|
|
563
|
+
### Graphics and Trademarks
|
|
564
|
+
|
|
565
|
+
The graphics and trademarks included in this repository are not covered by the MIT License. Please contact <a href="mailto:support@2captcha.com">support</a> for permissions regarding the use of these materials.
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
<!-- Shared links for README.md -->
|
|
504
569
|
[2Captcha]: https://2captcha.com/
|
|
505
|
-
[2captcha
|
|
570
|
+
[2captcha software catalog]: https://2captcha.com/software
|
|
506
571
|
[pingback settings]: https://2captcha.com/setting/pingback
|
|
507
572
|
[post options]: https://2captcha.com/2captcha-api#normal_post
|
|
508
573
|
[list of supported languages]: https://2captcha.com/2captcha-api#language
|
|
@@ -511,3 +576,4 @@ Examples of solving all supported captcha types are located in the [examples] di
|
|
|
511
576
|
[Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
|
|
512
577
|
[Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
|
|
513
578
|
[examples]: ./examples
|
|
579
|
+
[residential proxies]: https://2captcha.com/proxy/residential-proxies
|
|
@@ -27,6 +27,15 @@ setup(name='2captcha-python',
|
|
|
27
27
|
"Programming Language :: Python :: 3",
|
|
28
28
|
"License :: OSI Approved :: MIT License",
|
|
29
29
|
"Operating System :: OS Independent",
|
|
30
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
31
|
+
"Topic :: Scientific/Engineering :: Image Recognition",
|
|
32
|
+
"Topic :: Utilities",
|
|
33
|
+
"Intended Audience :: Developers",
|
|
30
34
|
],
|
|
35
|
+
keywords=[
|
|
36
|
+
'2captcha', 'captcha', 'api', 'captcha solver', 'reCAPTCHA', 'hCaptcha',
|
|
37
|
+
'FunCaptcha', 'Geetest', 'image captcha', 'Coordinates', 'Click Captcha',
|
|
38
|
+
'Geetest V4', 'Lemin captcha', 'Amazon WAF', 'Cloudflare Turnstile',
|
|
39
|
+
'Capy Puzzle', 'MTCaptcha', 'Friendly Captcha', 'Tencent', 'Cutcaptcha', 'DataDome'],
|
|
31
40
|
python_requires='>=3.6',
|
|
32
41
|
test_suite='tests')
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from .abstract import AbstractTest
|
|
7
|
+
except ImportError:
|
|
8
|
+
from abstract import AbstractTest
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DatadomeTest(AbstractTest):
|
|
12
|
+
|
|
13
|
+
def test_all_params(self):
|
|
14
|
+
params = {
|
|
15
|
+
'captcha_url': 'https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMAZirHgKBVrxwAsVuKlQ%3D%3D&c',
|
|
16
|
+
'pageurl': 'https://mysite.com/page/with/datadome',
|
|
17
|
+
'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
|
|
18
|
+
'proxy': {'type': 'HTTP', 'uri': 'login:password@IP_address:PORT'}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
sends = {
|
|
22
|
+
'method': 'datadome',
|
|
23
|
+
'captcha_url': 'https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMAZirHgKBVrxwAsVuKlQ%3D%3D&c',
|
|
24
|
+
'pageurl': 'https://mysite.com/page/with/datadome',
|
|
25
|
+
'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
|
|
26
|
+
'proxy': 'login:password@IP_address:PORT',
|
|
27
|
+
'proxytype': 'HTTP'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return self.send_return(sends, self.solver.datadome, **params)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if __name__ == '__main__':
|
|
34
|
+
unittest.main()
|
|
@@ -810,6 +810,30 @@ class TwoCaptcha():
|
|
|
810
810
|
**kwargs)
|
|
811
811
|
return result
|
|
812
812
|
|
|
813
|
+
def datadome(self, captcha_url, pageurl, userAgent, proxy, **kwargs):
|
|
814
|
+
"""Wrapper for solving DataDome Captcha.
|
|
815
|
+
|
|
816
|
+
Parameters
|
|
817
|
+
__________
|
|
818
|
+
captcha_url: str
|
|
819
|
+
The value of the 'src' parameter for the 'iframe' element containing the captcha on the page.
|
|
820
|
+
pageurl: str
|
|
821
|
+
Full URL of the page that triggers the captcha when you go to it.
|
|
822
|
+
userAgent: str
|
|
823
|
+
User-Agent of the browser that will be used by the employee when loading the captcha.
|
|
824
|
+
proxy : dict
|
|
825
|
+
{'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}.
|
|
826
|
+
"""
|
|
827
|
+
|
|
828
|
+
result = self.solve(method='datadome',
|
|
829
|
+
captcha_url=captcha_url,
|
|
830
|
+
pageurl=pageurl,
|
|
831
|
+
userAgent=userAgent,
|
|
832
|
+
proxy=proxy,
|
|
833
|
+
**kwargs)
|
|
834
|
+
|
|
835
|
+
return result
|
|
836
|
+
|
|
813
837
|
def solve(self, timeout=0, polling_interval=0, **kwargs):
|
|
814
838
|
'''Sends captcha, receives result.
|
|
815
839
|
|
{2captcha_python-1.2.7 → 2captcha_python-1.3.0}/2captcha_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|