Turnstile¶
To import this module:
from python3_anticaptcha.turnstile import Turnstile
- class python3_anticaptcha.turnstile.Turnstile(api_key: str, captcha_type: CaptchaTypeEnm | str, websiteURL: str, websiteKey: str, action: str | None = None, turnstileCData: str | None = None, proxyType: ProxyTypeEnm | str | None = None, proxyAddress: str | None = None, proxyPort: int | None = None, proxyLogin: str | None = None, proxyPassword: str | None = None, sleep_time: int | None = 10)¶
- __init__(api_key: str, captcha_type: CaptchaTypeEnm | str, websiteURL: str, websiteKey: str, action: str | None = None, turnstileCData: str | None = None, proxyType: ProxyTypeEnm | str | None = None, proxyAddress: str | None = None, proxyPort: int | None = None, proxyLogin: str | None = None, proxyPassword: str | None = None, sleep_time: int | None = 10)¶
The class is used to work with Turnstile.
- Parameters:
api_key (str) – Capsolver API key
captcha_type (CaptchaTypeEnm | str) – Captcha type
websiteURL (str) – Address of the webpage
websiteKey (str) – Turnstile sitekey
proxyType (ProxyTypeEnm | str | None) – Type of the proxy
proxyAddress (str | None) – Proxy IP address IPv4/IPv6. Not allowed to use: host names instead of IPs, transparent proxies (where client IP is visible), proxies from local networks (192.., 10.., 127…)
proxyPort (int | None) – Proxy port.
sleep_time (int | None) – The waiting time between requests to get the result of the Captcha
Examples
>>> Turnstile(api_key="99d7d111a0111dc11184111c8bb111da", ... captcha_type="TurnstileTaskProxyless", ... websiteURL="https://rucaptcha.com/demo/cloudflare-turnstile", ... websiteKey="0x4AAAAAAAC3DHQFLr1GavRN" ... ).captcha_handler() { "errorId": 0, "errorCode": None, "errorDescription": None, "status":"ready", "solution":{ "token":"0.Qz0.....f1", "userAgent":"Mozilla/.....36" }, "cost": 0.002, "ip": "46.53.249.230", "createTime": 1679004358, "endTime": 1679004368, "solveCount": 0, "taskId": 396687629 }
>>> await Turnstile(api_key="99d7d111a0111dc11184111c8bb111da", ... captcha_type="TurnstileTaskProxyless", ... websiteURL="https://rucaptcha.com/demo/cloudflare-turnstile", ... websiteKey="0x4AAAAAAAC3DHQFLr1GavRN" ... ).aio_captcha_handler() { "errorId": 0, "errorCode": None, "errorDescription": None, "status":"ready", "solution":{ "token":"0.Qz0.....f1", "userAgent":"Mozilla/.....36" }, "cost": 0.002, "ip": "46.53.249.230", "createTime": 1679004358, "endTime": 1679004368, "solveCount": 0, "taskId": 396687629 }
>>> Turnstile(api_key="99d7d111a0111dc11184111c8bb111da", ... captcha_type="TurnstileTaskProxyless", ... websiteURL="https://rucaptcha.com/demo/cloudflare-turnstile", ... websiteKey="0x4AAAAAAAC3DHQFLr1GavRN", ... proxyType="http", ... proxyAddress="0.0.0.0", ... proxyPort=9988, ... ).captcha_handler() { "errorId": 0, "errorCode": None, "errorDescription": None, "status":"ready", "solution":{ "token":"0.Qz0.....f1", "userAgent":"Mozilla/.....36" }, "cost": 0.002, "ip": "46.53.249.230", "createTime": 1679004358, "endTime": 1679004368, "solveCount": 0, "taskId": 396687629 }
>>> Turnstile(api_key="99d7d111a0111dc11184111c8bb111da", ... captcha_type="TurnstileTaskProxyless", ... websiteURL="https://rucaptcha.com/demo/cloudflare-turnstile", ... websiteKey="0x4AAAAAAAC3DHQFLr1GavRN", ... proxyType="http", ... proxyAddress="0.0.0.0", ... proxyPort=9988 ... ).captcha_handler(proxyLogin="some_login", ... proxyPassword="some_strong_password") { "errorId": 0, "errorCode": None, "errorDescription": None, "status":"ready", "solution":{ "token":"0.Qz0.....f1", "userAgent":"Mozilla/.....36" }, "cost": 0.002, "ip": "46.53.249.230", "createTime": 1679004358, "endTime": 1679004368, "solveCount": 0, "taskId": 396687629 }
- captcha_handler(**additional_params) dict ¶
Synchronous method for captcha solving
- Parameters:
additional_params – Some additional parameters that will be used in creating the task and will be passed to the payload under
task
key. LikeproxyLogin
,proxyPassword
and etc. - more info in service docs- Returns:
Dict with full server response
- Return type:
dict
Notes
Check class docstirng for more info
- async aio_captcha_handler(**additional_params) dict ¶
Asynchronous method for captcha solving
- Parameters:
additional_params – Some additional parameters that will be used in creating the task and will be passed to the payload under
task
key. LikeproxyLogin
,proxyPassword
and etc. - more info in service docs- Returns:
Dict with full server response
- Return type:
dict
Notes
Check class docstirng for more info