Bypassing Cloudflare Turnstile
In this blog post, we'll focus on how to programmatically bypass Cloudflare Turnstile using Capsolver API. This can be particularly useful for developers who are working on projects that require automating tasks that involve interacting with Cloudflare Turnstile protected websites.
Understanding Cloudflare Turnstile
Cloudflare Turnstile is a service that protects websites from bots and spam by presenting users with a challenge that needs to be solved to prove that they're human. Capsolver provides support for various types of Cloudflare Turnstile tasks. In this blog post, we'll be focusing on AntiCloudflareTask
type.
This task type requires your own proxies. We support most Cloudflare protected sites, including 5s challenge, turnstile, captcha and other sites with verification mode. But since the site mode can be customized, if your site does not support please contact us.
The Turnstile/Challenge verification code is another attempt to replace reCaptcha/hCaptcha. We automatically support all of its subtypes:
- turnstile
- Manually
- Non-Interactive
- InVisible
- challenge
- 5s challenge
- Non-Interactive turnstile
- Non-Interactive hCaptcha
There is no need to specify subtypes during your call. It is not necessary to provide your own custom User-Agent
yet, we will ignore this parameter.
Creating a Task for Cloudflare Turnstile
To bypass Cloudflare Turnstile, the first step involves creating a task with the createTask method. This requires you to provide certain details like the type of task, the URL of the website using Cloudflare Turnstile, the Turnstile website key, and more. Here's an overview of the task object structure:
{
"type": "AntiCloudflareTask",
"websiteURL": "URL of the website using Cloudflare Turnstile",
"websiteKey": "Turnstile website key",
"metadata": {
"type": "challenge or turnstile",
"acton": "The value of the data-action attribute of the Turnstile element if it exists",
"cdata": "The value of the data-cdata attribute of the Turnstile element if it exists"
},
"proxy": "Proxy details"
}
You can send a POST request to create a task using the Capsolver API like this:
{
"clientKey":"YOUR_API_KEY",
"task":{
"type": "AntiCloudflareTask",
"websiteURL":"https://website-url.com/",
"websiteKey":"website-key",
"proxy":"Your_own_proxy"
}
}
Once you've submitted the task, you should receive a 'Task ID' in the response if it's successful
Retrieving the Result of the Task
After you've created the task, you can retrieve the result using the getTaskResult method. Depending on the system load, the results can be obtained within an interval of 1 to 20 seconds. Here's an example of a POST request to get the task result:
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"taskId": "Task ID received from the createTask method"
}
Once the task status is ready, you should receive the result of the Cloudflare Turnstile challenge in the response
Solving Cloudflare Turnstile with Python using Capsolver SDK:
Capsolver provides SDKs for Python. This makes it easier to integrate Capsolver into your existing projects. Here's an example of how to use the Capsolver SDK in Python to solve the Cloudflare Turnstile:
# pip install --upgrade capsolver
# export CAPSOLVER_API_KEY='...'
import capsolver
# capsolver.api_key = "..."
solution = capsolver.solve({
"type": "AntiCloudflareTask",
"websiteURL": "URL of the website using Cloudflare Turnstile",
"websiteKey": "Turnstile website key",
"proxy": "Your_own_proxy"
})
In the above code, YOUR_API_KEY should be replaced with your CapSolver API key, URL should be replaced with the URL of the website, "websiteKey" should be replaced with the Turnstile website key, and the "proxy" field should be replaced with the details of your proxye. The solve function sends a request to create a task to solve the captcha, and it will return the solution when it's ready
Pricing
For information on pricing, please visit our pricing page.
Bypass Cloudflare Turnstile in any programming language (C#/PYTHON/JAVASCRIPT/PHP):
Visit this page
Capsolver Team 💜
More Information of how to solve FunCaptcha
Visit this page
Capsolver Team 💜