Skip to content

Commit 9fe05d6

Browse files
Merge branch 'master' into RC-2938-cybersiara
2 parents 1b130c0 + ba2ea80 commit 9fe05d6

6 files changed

Lines changed: 117 additions & 4 deletions

File tree

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Examples of API requests for different captcha types are available on the [Pytho
4141
- [Friendly Captcha](#friendly-captcha)
4242
- [Cutcaptcha](#cutcaptcha)
4343
- [Tencent](#tencent)
44+
- [Datadome](#datadome)
4445
- [CyberSiARA](#cybersiara)
4546
- [Other methods](#other-methods)
4647
- [send / get_result](#send--get_result)
@@ -408,6 +409,26 @@ result = solver.tencent(app_id="197326679",
408409
param1=..., ...)
409410
```
410411

412+
### DataDome
413+
414+
<sup>[API method description.](https://2captcha.com/2captcha-api#datadome)</sup>
415+
416+
Use this method to solve DataDome captcha.
417+
418+
> [!IMPORTANT]
419+
> To solve the DataDome captcha, you must use a proxy. It is recommended to use [residential proxies].
420+
421+
```python
422+
result = solver.datadome(captcha_url="https://geo.captcha-delivery.com/captcha/?initialCid=...",
423+
pageurl="https://mysite.com/page/with/datadome",
424+
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",
425+
proxy={
426+
'type': 'HTTP',
427+
'uri': 'login:password@IP_address:PORT'
428+
},
429+
param1=..., ...)
430+
```
431+
411432
### CyberSiARA
412433

413434
<sup>[API method description.](https://2captcha.com/2captcha-api#cybersiara)</sup>
@@ -493,7 +514,8 @@ except TimeoutException as e:
493514
## Proxies
494515

495516
You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha,
496-
keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha, cybersiara.
517+
keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha, Tencent, DataDome, cybersiara.
518+
497519

498520
The proxy will be forwarded to the API to solve the captcha.
499521

@@ -568,3 +590,4 @@ The graphics and trademarks included in this repository are not covered by the M
568590
[Buy residential proxies]: https://2captcha.com/proxy/residential-proxies
569591
[Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true
570592
[examples]: ./examples
593+
[residential proxies]: https://2captcha.com/proxy/residential-proxies

examples/datadome.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import sys
2+
import os
3+
import json
4+
5+
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
6+
7+
from twocaptcha import TwoCaptcha
8+
9+
# in this example we store the API key inside environment variables that can be set like:
10+
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
11+
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
12+
# you can just set the API key directly to it's value like:
13+
# api_key="1abc234de56fab7c89012d34e56fa7b8"
14+
15+
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
16+
17+
solver = TwoCaptcha(api_key)
18+
19+
try:
20+
result = solver.datadome(
21+
captcha_url="https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAAAAMAZirHgKBVrxwAsVuKlQ%3D%3D&c...",
22+
pageurl="https://mysite.com/page/with/datadome",
23+
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",
24+
proxy={
25+
'type': 'HTTP',
26+
'uri': 'login:password@IP_address:PORT'
27+
}
28+
)
29+
30+
except Exception as e:
31+
sys.exit(e)
32+
33+
else:
34+
sys.exit('result: ' + str(result))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ def get_version():
3636
'2captcha', 'captcha', 'api', 'captcha solver', 'reCAPTCHA', 'hCaptcha',
3737
'FunCaptcha', 'Geetest', 'image captcha', 'Coordinates', 'Click Captcha',
3838
'Geetest V4', 'Lemin captcha', 'Amazon WAF', 'Cloudflare Turnstile',
39-
'Capy Puzzle', 'MTCaptcha', 'Friendly Captcha', 'Tencent', 'cybersiara'],
39+
'Capy Puzzle', 'MTCaptcha', 'Friendly Captcha', 'Tencent', 'Cutcaptcha', 'DataDome', 'cybersiara'],
4040
python_requires='>=3.6',
4141
test_suite='tests')

tests/test_datadome.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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()

twocaptcha/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"""
1313

1414
__author__ = '2captcha'
15-
__version__ = '1.2.8'
15+
__version__ = '1.3.0'

twocaptcha/solver.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,29 @@ def cutcaptcha(self, misery_key, apikey, url, **kwargs):
810810
**kwargs)
811811
return result
812812

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+
return result
835+
813836
def cybersiara(self, master_url_id, pageurl, userAgent, **kwargs):
814837
'''Wrapper for solving CyberSiARA captcha.
815838
@@ -829,7 +852,6 @@ def cybersiara(self, master_url_id, pageurl, userAgent, **kwargs):
829852
pageurl=pageurl,
830853
userAgent=userAgent,
831854
**kwargs)
832-
833855
return result
834856

835857
def solve(self, timeout=0, polling_interval=0, **kwargs):

0 commit comments

Comments
 (0)