Skip to content

Commit 553580d

Browse files
authoredDec 12, 2024
Merge pull request #116 from Sepera-okeq/master
Add Yandex Smart Solver
2 parents 42c90a5 + 9fe65b5 commit 553580d

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
 

‎README.md

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Examples of API requests for different captcha types are available on the [Pytho
2626
- [FunCaptcha](#funcaptcha)
2727
- [GeeTest](#geetest)
2828
- [GeeTest v4](#geetest-v4)
29+
- [Yandex Smart](#yandex-smart)
2930
- [Lemin Cropped Captcha](#lemin-cropped-captcha)
3031
- [Cloudflare Turnstile](#cloudflare-turnstile)
3132
- [Amazon WAF](#amazon-waf)
@@ -238,6 +239,18 @@ result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d90
238239

239240
```
240241

242+
### Yandex Smart
243+
244+
<sup>[API method description.](https://2captcha.com/2captcha-api#yandex-smart)</sup>
245+
246+
Use this method to solve Yandex Smart Captcha. Returns JSON with the token.
247+
```python
248+
result = solver.yandex_smart(sitekey='0x1AAAAh45AAAAkg0s2VIOD34y5hy4h4h',
249+
url='http://mysite.com/',
250+
softId=123,
251+
proxy={'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'},
252+
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')
253+
```
241254

242255
### Cloudflare Turnstile
243256

‎tests/test_yandex_smart_captcha.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 YandexSmartCaptchaTest(AbstractTest):
12+
13+
def test_all_params(self):
14+
params = {
15+
'sitekey': 'FEXfAbHQsToo97VidNVk3j4dC74nGW1DgdxjtNB9',
16+
'url': 'https://captcha-api.yandex.ru/demo',
17+
}
18+
19+
sends = {
20+
'method': 'yandex',
21+
'sitekey': 'FEXfAbHQsToo97VidNVk3j4dC74nGW1DgdxjtNB9',
22+
'pageurl': 'https://captcha-api.yandex.ru/demo',
23+
}
24+
25+
return self.send_return(sends, self.solver.yandex_smart, **params)
26+
27+
28+
if __name__ == '__main__':
29+
unittest.main()

‎twocaptcha/solver.py

+27
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,33 @@ def cybersiara(self, master_url_id, pageurl, userAgent, **kwargs):
856856
**kwargs)
857857
return result
858858

859+
def yandex_smart(self, sitekey, url, **kwargs):
860+
'''Wrapper for solving Yandex Smart.
861+
862+
Parameters
863+
__________
864+
sitekey : str
865+
The value of data-sitekey attribute of captcha's div element on page.
866+
url : str
867+
Full URL of the page where you solve the captcha.
868+
softId : int, optional
869+
ID of software developer. Developers who integrated their software with 2Captcha get reward: 10% of
870+
spendings of their software users.
871+
callback : str, optional
872+
URL for pingback (callback) response that will be sent when captcha is solved. URL should be registered on
873+
the server. More info here https://2captcha.com/2captcha-api#pingback.
874+
proxy : dict, optional
875+
{'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}.
876+
userAgent: str, optional
877+
User-Agent of the browser that will be used by the employee when loading the captcha.
878+
'''
879+
880+
result = self.solve(sitekey=sitekey,
881+
url=url,
882+
method='yandex',
883+
**kwargs)
884+
return result
885+
859886
def solve(self, timeout=0, polling_interval=0, **kwargs):
860887
'''Sends captcha, receives result.
861888

0 commit comments

Comments
 (0)