CAPSOLVER
Blog
How to solve Cloudflare Challenge (5s)

How to solve Cloudflare Challenge

Logo of CapSolver

Lucas Mitchell

Automation Engineer

11-May-2023

How to solve Cloudflare Challenge

Challenges Supported by Capsolver

  • Challenge + Turnstile

  • Challenge

If it's challenge + captcha, you don't need to put any special parameter in the createTask, as we will recognize that require to solve the captcha.

How to solve Cloudflare Challenge (5s IUAM)

Before we start solving Cloudflare, there are some requeriments and points that we need to be aware that they are needed to know
Requeriments:

  • Capsolver Key
  • Proxy

Points to be aware that if we don't follow, solution will be invalid:

  • Token returned in the response of the method getTaskResult is the value of the cookie cf_clearance that you will need to create.
  • Must use the same user-agent that the method getTaskResult return
  • Must use the same proxy IP used for solve the challenge
  • Must use the cookies of the response
  • Must use the headers of the response
  • Use TLS chrome 120 version

To solve cloudflare challenge, follow our documentation. Some parameters are required and some are optional.
For this example, we will only use the required parameters. The task types for cloudflare are:

  • AntiCloudflareTask: This task type requires your own proxies.

We will use AntiCloudflareTask as the site uses Cloudflare Challenge 5s.
If any parameters are missing or you don't submit correctly, you will likely encounter issues with the token not being accepted by the website. You can find all the parameters in this picture:

Task Object Structure for solve Cloudflare Challenge 5s (cf_clearance)

Step 1: Submitting the information to capsolver

Use the method createTask to submit the information required:

JSON Copy
POST https://api.capsolver.com/createTask

{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "AntiCloudflareTask",
    "websiteURL": "https://www.yourwebsite.com",
    "proxy": "158.120.100.23:334:user:pass"
  }
}

Step 2: Getting the results

To verify the results, you'll need to continuously poll the getTaskResult API endpoint until the captcha is resolved.

Here's an example request:

json Copy
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json

{
    "clientKey":"YOUR_API_KEY",
    "taskId": "TASKID_OF_CREATETASK" //ID created by the createTask method
}

Once the captcha is successfully resolved, you'll receive a response similar to the one depicted in the following image:

markdown Copy
{
    "errorId": 0,
    "taskId": "d8d3a8b4-30cc-4b09-802a-a476ca17fa54",
    "status": "ready",
    "solution": {
        "accept-language": "en-US,en;q=0.9",
        "cookies": {

        },
        "headers": {
            "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
            "accept-encoding": "gzip, deflate, br",
            "accept-language": "en-US,en;q=0.9",
            "cache-control": "max-age=0",
            "content-type": "application/x-www-form-urlencoded",
            "origin": "",
            "referer": "",
            "sec-ch-ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\"",
            "sec-ch-ua-arch": "\"arm\"",
            "sec-ch-ua-bitness": "\"64\"",
            "sec-ch-ua-full-version": "\"120.0.6099.71\"",
            "sec-ch-ua-full-version-list": "\"Not_A Brand\";v=\"8.0.0.0\", \"Chromium\";v=\"120.0.6099.71\", \"Google Chrome\";v=\"120.0.6099.71\"",
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-model": "\"\"",
            "sec-ch-ua-platform": "\"macOS\"",
            "sec-ch-ua-platform-version": "\"10.14.6\"",
            "sec-fetch-dest": "document",
            "sec-fetch-mode": "navigate",
            "sec-fetch-site": "same-origin",
            "sec-fetch-user": "?1",
            "upgrade-insecure-requests": "1",
            "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
        },
        "proxy": "your proxy",
        "token": "cf clearance token",
        "type": "challenge",
        "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    }
}

The captcha token received can be verified by submitting the cookie cf_clearance with the value of the response token, use the same proxy IP used for solve the challenge, cookies, TLS chrome 120, headers and also the same user-agent that we return you in the response to the relevant site.

⚠ If the token is rejected, it may indicate that some information is missing or incorrect. Make sure that you are submitting the token value correctly to the cookie cf_clearance, that you are using the same proxy IP used for solve the challenge, TLS chrome 120, headers of the response and also the same user-agent that it's returned to you in the response.

If you want to solve Cloudflare Turnstile Captcha. Please refer to this blog: link

In conclusion, while solving cloudflare challenge may seem a daunting task, capsolver.com makes the process swift and efficient. By following the steps outlined above, you can easily resolve cloudflare.

Capsolver Team 💜

Compliance Disclaimer: The information provided on this blog is for informational purposes only. CapSolver is committed to compliance with all applicable laws and regulations. The use of the CapSolver network for illegal, fraudulent, or abusive activities is strictly prohibited and will be investigated. Our captcha-solving solutions enhance user experience while ensuring 100% compliance in helping solve captcha difficulties during public data crawling. We encourage responsible use of our services. For more information, please visit our Terms of Service and Privacy Policy.

More