Skip to content

Commit

Permalink
Merge pull request #110 from 2captcha/RC-2938-cybersiara
Browse files Browse the repository at this point in the history
RC-2938-cybersiara
  • Loading branch information
dzmitry-duboyski authored Aug 30, 2024
2 parents ba2ea80 + 9fe05d6 commit 40d9410
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 2 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Examples of API requests for different captcha types are available on the [Pytho
- [Cutcaptcha](#cutcaptcha)
- [Tencent](#tencent)
- [Datadome](#datadome)
- [CyberSiARA](#cybersiara)
- [Other methods](#other-methods)
- [send / get_result](#send--get_result)
- [balance](#balance)
Expand Down Expand Up @@ -428,6 +429,18 @@ result = solver.datadome(captcha_url="https://geo.captcha-delivery.com/captcha/?
param1=..., ...)
```

### CyberSiARA

<sup>[API method description.](https://2captcha.com/2captcha-api#cybersiara)</sup>

Use this method to solve CyberSiARA. Returns a token.
```python
result = solver.cybersiara(master_url_id='tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv',
pageurl='https://demo.mycybersiara.com/',
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',
param1=..., ...)
```

## Other methods

### send / get_result
Expand Down Expand Up @@ -501,7 +514,8 @@ except TimeoutException as e:
## Proxies

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


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

Expand Down
30 changes: 30 additions & 0 deletions examples/cybersiara.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys
import os

sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

from twocaptcha import TwoCaptcha

# in this example we store the API key inside environment variables that can be set like:
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
# you can just set the API key directly to it's value like:
# api_key="1abc234de56fab7c89012d34e56fa7b8"

api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')


solver = TwoCaptcha(api_key)

try:
result = solver.cybersiara(
master_url_id='tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv',
pageurl='https://demo.mycybersiara.com/',
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',
)

except Exception as e:
sys.exit(e)

else:
sys.exit('result: ' + str(result))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ def get_version():
'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'],
'Capy Puzzle', 'MTCaptcha', 'Friendly Captcha', 'Tencent', 'Cutcaptcha', 'DataDome', 'cybersiara'],
python_requires='>=3.6',
test_suite='tests')
32 changes: 32 additions & 0 deletions tests/test_cybersiara.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3

import unittest

try:
from .abstract import AbstractTest
except ImportError:
from abstract import AbstractTest


class CybersiaraTest(AbstractTest):

def test_all_params(self):
params = {
'master_url_id': 'tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv',
'pageurl': 'https://demo.mycybersiara.com/',
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36',
}

sends = {
'method': 'cybersiara',
'master_url_id': 'tpjOCKjjpdzv3d8Ub2E9COEWKt1vl1Mv',
'pageurl': 'https://demo.mycybersiara.com/',
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36',
}

return self.send_return(sends, self.solver.cybersiara, **params)


if __name__ == '__main__':
unittest.main()

20 changes: 20 additions & 0 deletions twocaptcha/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,27 @@ def datadome(self, captcha_url, pageurl, userAgent, proxy, **kwargs):
userAgent=userAgent,
proxy=proxy,
**kwargs)
return result

def cybersiara(self, master_url_id, pageurl, userAgent, **kwargs):
'''Wrapper for solving CyberSiARA captcha.
Parameters
__________
master_url_id : str
The value of the MasterUrlId parameter from the request to API/CyberSiara/GetCyberSiara.
pageurl : str
Full URL of the page with captcha.
userAgent : str
User-Agent of your browser.
proxy : dict, optional
{'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}.
'''
result = self.solve(method='cybersiara',
master_url_id=master_url_id,
pageurl=pageurl,
userAgent=userAgent,
**kwargs)
return result

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

0 comments on commit 40d9410

Please sign in to comment.