How to Solve Cloudflare Challenge with CaptchaAI. Step-by-Step Tutorial

Learn how to solve Cloudflare challenge instantly using CaptchaAI’s high-accuracy, unlimited, and automated solution.

5 views ·Updated 1 hour ago ·4 min read

Note: This tutorial assumes you're using CaptchaAI API to bypass Cloudflare Challenge pages programmatically (e.g., in a script or automated tool).

Prerequisites

  • A CaptchaAI API key.
  • HTTP client (curl, Postman, Python requests, etc.).
  • Target URL showing Cloudflare Challenge.
  • The exact same proxy used to access the target page in your browser/script .
  • Basic knowledge of browser cookies and proxy configuration.

Step 1: Prepare Proxy & Target URL

  1. Prepare a supported proxy (HTTP, HTTPS, SOCKS4, or SOCKS5).
  1. Prepare the full URL (e.g., https://examples.captchaai.com/cfchallenge.html).

Critical: The proxy in your API request MUST match the proxy used to load the challenge page. Cloudflare binds solutions to IP + user-agent.


Step 2: Submit Cloudflare Challenge Task to CaptchaAI

Send the challenge details to CaptchaAI:

API Request (POST)

POST https://ocr.captchaai.com/in.php

Form Data:

key=YOUR_API_KEY
method=cloudflare_challenge
pageurl=https://examples.captchaai.com/cfchallenge.html
proxy=user:password@111.111.111.111:8080
proxytype=HTTP
json=1

Replace:

  • YOUR_API_KEY → Your CaptchaAI key
  • pageurl → Full challenge page URL
  • proxy → Your proxy credentials + IP:port
  • proxytype → Your proxy protocol

Example (curl)

curl https://ocr.captchaai.com/in.php \
   -F "key=YOUR_API_KEY" \  
   -F "method=cloudflare_challenge" \  
   -F "pageurl=https://example.com/login" \  
   -F "proxy=user:pass@111.111.111.111:8080" \  
   -F "proxytype=HTTP" \ 
   -F "json=1" \ 

Expected Response

{     
"status": 1,     
"request": 74965409378   
}

Save the numeric ID (74965409378) — this is your task ID.


Step 3: Poll for Result

Give CaptchaAI a few seconds to solve the challenge, then poll every 5 seconds until you receive the result:

API Request (GET)

GET https://ocr.captchaai.com/res.php?key=YOUR_API_KEY&action=get&id=74965409378&json=1

Replace:

  • YOUR_API_KEY → Your CaptchaAI key
  • id → The id received on task submission

Example (curl)

curl https://ocr.captchaai.com/res.php \
 -F "key=YOUR_API_KEY" \
 -F "action=get" \
 -F "id=1234567890" \
 -F "json=1"

Polling Logic

  • Send this request every 5 seconds.
  • If status=1 and request=CAPCHA_NOT_READY, wait and retry.
  • If status=1, you’ve got your token!

Example Response

{  
"status": 1,  
"result": "B3kdY0jp5ksYG3SVAI...3Jg5b3b9oTBAP94E",  
"user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0"  
}

result = Your cf_clearance cookie value. user_agent = Use this as your browser User Agent.


Step 4: Solution Usage

For Browser Automation using our User Agent (Python × Playwright):

  1. Open a new browser instance and use your proxy & user_agent from Step 3.

    from playwright.sync_api import sync_playwright
    
       # Custom configuration
       user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0"
    
       # Proxy with authentication
       proxy = {
          "server": "http://111.111.111.111:8080",    # Replace with your proxy IP and port
          "username": "user",            # Replace with your proxy username
          "password": "password"         # Replace with your proxy password
       }
    
       with sync_playwright() as p:
          # Launch browser with proxy
          browser = p.chromium.launch(proxy=proxy, headless=False)
    
          # Open new browser context with custom user agent
          context = browser.new_context(user_agent=user_agent)
    
          # Open a new page
          page = context.new_page()
    
  2. Navigate the challenge page in your browser using your proxy.

    page.goto("https://examples.captchaai.com/cfchallenge.html")
    
  3. Inject cookie:
    The Cookie Formation:

    browser.add_cookies([{'name': 'cf_clearance', 'value': "B3kdY0jp5ksYG3SVAI...3Jg5b3b9oTBAP94E", 'domain': "captchaai.com", 'path': '/'}
    
  • Name: cf_clearance
  • Value:result value
  • Domain: Target site domain (e.g., captchaai.com)
  • Path: Current path, usually /
  • Secure: true (if HTTPS site)
  1. Refresh the page

    page.reload()
    

For HTTP Clients (Python Example):

import requests  

cookies = {"cf_clearance": "B3kdY0jp5ksYG3SVAI...3Jg5b3b9oTBAP94E"}  
headers = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64)..."}  # Use EXACT UA from API  

response = requests.get("https://example.com/login", cookies=cookies, headers=headers)  
print(response.text)  # Full page content!

Step 5: Verify Success

✔️ Page loads without challenge → Success!
❌ Challenge reappears → Re-solve (cookie may be expired or proxy/UA mismatched)


Tips

  • Always use json=1 to receive User Agent value.
  • Proxy consistency is non-negotiable.
  • Using the returned User Agent value is highly recommend. cai_cfchallenge_helpcenter.md Displaying cai_cfchallenge_helpcenter.md.