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, proxyType: ProxyTypeEnm | str | None = None, proxyAddress: str | None = None, proxyPort: int | None = None, sleep_time: int | None = 10, **kwargs)
__init__(api_key: str, captcha_type: CaptchaTypeEnm | str, websiteURL: str, websiteKey: str, proxyType: ProxyTypeEnm | str | None = None, proxyAddress: str | None = None, proxyPort: int | None = None, sleep_time: int | None = 10, **kwargs)

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

  • kwargs – Additional not required params for main request body. Like callbackUrl/languagePool and etc. More info - https://anti-captcha.com/apidoc/methods/createTask

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. Like proxyLogin, proxyPassword and etc. - more info in service docs

Returns:

Full service 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. Like proxyLogin, proxyPassword and etc. - more info in service docs

Returns:

Full service response

Return type:

dict

Notes

Check class docstirng for more info