Use Cases

Tự động xử lý Bot CAPTCHA bằng CaptchaAI

Các bot tự động hóa xử lý các tác vụ lặp lại — gửi biểu mẫu, tạo tài khoản, nhập dữ liệu, giám sát. CAPTCHA làm gián đoạn các quy trình công việc này. CaptchaAI giải CAPTCHA theo chương trình để bot của bạn chạy mà không cần sự can thiệp của con người.

Các kịch bản tự động hóa phổ biến

Kịch bản CAPTCHA điển hình Phương pháp CaptchaAI
Gửi biểu mẫu reCAPTCHA v2 method=userrecaptcha
Đăng ký tài khoản reCAPTCHA v2/v3 method=userrecaptcha
Cổng nhập dữ liệu CAPTCHA hình ảnh method=base64
Booking/reservation Cloudflare Turnstile method=turnstile
Truy cập cổng API Cloudflare Challenge method=cloudflare_challenge

Khung Bot chung

Xây dựng khung bot giải CAPTCHA có thể tái sử dụng:

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)

Ví dụ: Bot gửi biểu mẫu

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}")

Ví dụ: Bot quy trình làm việc nhiều bước

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"}
)

Ví dụ: Bot nhập dữ liệu với hình ảnh 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))

Khung bot Node.js

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..."
);

Khắc phục sự cố

vấn đề sửa chữa
Mã thông báo CAPTCHA bị từ chối Sử dụng mã thông báo trong vòng 120 giây kể từ khi giải quyết
Bot được phát hiện mặc dù mã thông báo hợp lệ Thêm tiêu đề ẩn và yêu cầu trì hoãn
Biểu mẫu yêu cầu các trường bổ sung Kiểm tra nguồn biểu mẫu cho các trường ẩn (mã thông báo CSRF)
Tỷ lệ giới hạn khi gửi nhiều lần Thêm độ trễ và xoay proxy

Câu hỏi thường gặp

Các bot tự động hóa có thể xử lý bất kỳ loại CAPTCHA nào không?

Với CaptchaAI thì đúng vậy. API hỗ trợ reCAPTCHA (tất cả các phiên bản), Cloudflare Turnstile, GeeTest, hCaptcha, CAPTCHA hình ảnh, v.v. Khung bot của bạn chỉ cần phát hiện loại và gọi đúng phương thức.

Làm cách nào để chạy bot 24/7?

Sử dụng các công cụ lập lịch trình (cron, Trình lập lịch tác vụ, systemd) hoặc triển khai lên các chức năng đám mây. API CaptchaAI có sẵn 24/7 với hơn 99,9% thời gian hoạt động.

Còn các bot cần xử lý tính năng chống bot ngoài CAPTCHA thì sao?

Kết hợp CaptchaAI với các trình duyệt ẩn (không bị phát hiện-chromedriver, con rối-bổ sung). CaptchaAI xử lý lớp CAPTCHA; công cụ tàng hình xử lý việc phát hiện dấu vân tay.

Hướng dẫn liên quan

Os comentários estão desativados para este artigo.

Postagens relacionadas

Reference Tính bền vững phiên trình duyệt cho luồng QA CAPTCHA của bạn
Duy trì phiên trình duyệt qua nhiều bước trong kiểm thử QA CAPTCHA trên staging của bạn để giảm gián đoạn và tăng độ tái lập.

Duy trì phiên trình duyệt qua nhiều bước trong kiểm thử QA CAPTCHA trên staging của bạn để giảm gián đoạn và t...

Apr 30, 2026
Integrations Tách biệt hồ sơ trình duyệt cho QA với CaptchaAI
Tách cookie, storage, tài khoản kiểm thử và cấu hình CAPTCHA theo từng hồ sơ trình duyệt để giữ cho kiểm thử QA trong staging sạch và có thể tái lập.

Tách cookie, storage, tài khoản kiểm thử và cấu hình CAPTCHA theo từng hồ sơ trình duyệt để giữ cho kiểm thử Q...

Apr 29, 2026
API Tutorials Bash Script + cURL + CaptchaAI: Tự động hóa Shell CAPTCHA
Hướng dẫn từng bước cho Bash Script + c URL + Captcha AI: Tự động hóa Shell CAPTCHA, với các ví dụ có thể sử dụng lại trực tiếp và quy trình làm việc Captcha AI...

Hướng dẫn từng bước cho Bash Script + c URL + Captcha AI: Tự động hóa Shell CAPTCHA, với các ví dụ có thể sử d...

Apr 26, 2026