Automation bots handle repeatable tasks — form submissions, account creation, data entry, monitoring. CAPTCHAs interrupt these workflows. CaptchaAI solves CAPTCHAs programmatically so your bots run without human intervention.
Common Automation Scenarios
| Scenario | Typical CAPTCHA | CaptchaAI Method |
|---|---|---|
| Form submission | reCAPTCHA v2 | method=userrecaptcha |
| Account registration | reCAPTCHA v2/v3 | method=userrecaptcha |
| Data entry portals | Image CAPTCHA | method=base64 |
| Booking/reservation | Cloudflare Turnstile | method=turnstile |
| API gateway access | Cloudflare Challenge | method=cloudflare_challenge |
Generic Bot Framework
Build a reusable CAPTCHA-solving bot framework:
import requests
import time
import logging
logger = logging.getLogger(__name__)
class CaptchaBot:
def __init__(self, api_key):
self.api_key = api_key
self.session = requests.Session()
self.session.headers.update({
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
})
def solve(self, method, **params):
"""Solve any CAPTCHA type."""
params["key"] = self.api_key
params["method"] = method
resp = requests.get("https://ocr.captchaai.com/in.php", params=params)
if not resp.text.startswith("OK|"):
raise Exception(f"Submit error: {resp.text}")
task_id = resp.text.split("|")[1]
logger.info(f"Task submitted: {task_id}")
for _ in range(60):
time.sleep(5)
result = requests.get("https://ocr.captchaai.com/res.php", params={
"key": self.api_key, "action": "get", "id": task_id
})
if result.text == "CAPCHA_NOT_READY": continue
if result.text.startswith("OK|"): return result.text.split("|")[1]
raise Exception(f"Error: {result.text}")
raise TimeoutError("CAPTCHA solve timed out")
def submit_form(self, url, form_data, captcha_field="g-recaptcha-response",
site_key=None, captcha_method="userrecaptcha"):
"""Submit a form with CAPTCHA solving."""
if site_key:
if captcha_method == "userrecaptcha":
token = self.solve(captcha_method, googlekey=site_key, pageurl=url)
elif captcha_method == "turnstile":
token = self.solve(captcha_method, sitekey=site_key, pageurl=url)
form_data[captcha_field] = token
return self.session.post(url, data=form_data)
Example: Form Submission Bot
bot = CaptchaBot("YOUR_API_KEY")
# Submit a contact form protected by reCAPTCHA
result = bot.submit_form(
url="https://example.com/contact",
form_data={
"name": "John Doe",
"email": "john@example.com",
"message": "Inquiry about your service"
},
site_key="6Le-wvkS...",
captcha_method="userrecaptcha"
)
print(f"Form submitted: {result.status_code}")
Example: Multi-Step Workflow Bot
def appointment_booking_bot(date, time_slot, user_info):
bot = CaptchaBot("YOUR_API_KEY")
# Step 1: Load booking page
page = bot.session.get("https://example.com/book")
# Step 2: Select date and time
resp = bot.session.post("https://example.com/book/select", data={
"date": date,
"time": time_slot
})
# Step 3: Fill personal info with CAPTCHA
result = bot.submit_form(
url="https://example.com/book/confirm",
form_data={
"name": user_info["name"],
"email": user_info["email"],
"phone": user_info["phone"],
"date": date,
"time": time_slot
},
site_key="6Le-wvkS...",
captcha_method="userrecaptcha"
)
return result.status_code == 200
# Run
success = appointment_booking_bot(
date="2025-02-15",
time_slot="10:00",
user_info={"name": "John Doe", "email": "john@example.com", "phone": "555-0100"}
)
Example: Data Entry Bot with Image CAPTCHA
import base64
def data_entry_bot(entries, captcha_image_url):
bot = CaptchaBot("YOUR_API_KEY")
for entry in entries:
# Load the form page
page = bot.session.get("https://portal.example.com/entry")
# Download and solve image CAPTCHA
img = bot.session.get(captcha_image_url)
img_b64 = base64.b64encode(img.content).decode()
captcha_text = bot.solve("base64", body=img_b64)
# Submit entry
resp = bot.session.post("https://portal.example.com/entry", data={
**entry,
"captcha": captcha_text
})
logger.info(f"Entry submitted: {resp.status_code}")
time.sleep(random.uniform(2, 5))
Node.js Bot Framework
const axios = require("axios");
class CaptchaBot {
constructor(apiKey) {
this.apiKey = apiKey;
}
async solve(method, params) {
params.key = this.apiKey;
params.method = method;
const submit = await axios.get("https://ocr.captchaai.com/in.php", {
params,
});
const taskId = submit.data.split("|")[1];
while (true) {
await new Promise((r) => setTimeout(r, 5000));
const result = await axios.get("https://ocr.captchaai.com/res.php", {
params: { key: this.apiKey, action: "get", id: taskId },
});
if (result.data === "CAPCHA_NOT_READY") continue;
if (result.data.startsWith("OK|")) return result.data.split("|")[1];
throw new Error(result.data);
}
}
async submitForm(url, formData, siteKey, method = "userrecaptcha") {
const token = await this.solve(method, {
googlekey: siteKey,
pageurl: url,
});
formData["g-recaptcha-response"] = token;
return axios.post(url, new URLSearchParams(formData));
}
}
// Usage
const bot = new CaptchaBot("YOUR_API_KEY");
const result = await bot.submitForm(
"https://example.com/submit",
{ name: "John", email: "john@example.com" },
"6Le-wvkS..."
);
Troubleshooting
| Issue | Fix |
|---|---|
| CAPTCHA token rejected | Use token within 120 seconds of solving |
| Bot detected despite valid token | Add stealth headers and request delays |
| Form requires additional fields | Inspect the form source for hidden fields (CSRF tokens) |
| Rate limited on repeated submissions | Add delays and rotate proxies |
FAQ
Can automation bots handle any CAPTCHA type?
With CaptchaAI, yes. The API supports reCAPTCHA (all versions), Cloudflare Turnstile, GeeTest, hCaptcha, image CAPTCHAs, and more. Your bot framework just needs to detect the type and call the right method.
How do I run bots 24/7?
Use scheduling tools (cron, Task Scheduler, systemd) or deploy to cloud functions. The CaptchaAI API is available 24/7 with 99.9%+ uptime.
What about bots that need to handle anti-bot beyond CAPTCHAs?
Combine CaptchaAI with stealth browsers (undetected-chromedriver, puppeteer-extra). CaptchaAI handles the CAPTCHA layer; stealth tools handle fingerprint detection.
Discussions (0)
Join the conversation
Sign in to share your opinion.
Sign InNo comments yet.