Tài Liệu Tham Khảo

Di chuyển từ NextCaptcha sang CaptchaAI: Hướng dẫn đầy đủ

NextCaptcha sử dụng API REST dựa trên JSON với các điểm cuối /createTask/getTaskResult. CaptchaAI sử dụng định dạng in.php/3ZZ được áp dụng rộng rãi. Hướng dẫn này trình bày cách ánh xạ chính xác giữa hai API.

Ánh xạ điểm cuối

hành động Tiếp theoCaptcha CaptchaAI
Gửi nhiệm vụ POST /createTask POST https://ocr.captchaai.com/in.php
Nhận kết quả POST /getTaskResult GET https://ocr.captchaai.com/res.php
Kiểm tra số dư POST /getBalance GET res.php?action=getbalance&key=KEY

Yêu cầu sự khác biệt về cấu trúc

SauGửi Captcha (nội dung JSON)

{
  "clientKey": "next_captcha_key",
  "task": {
    "type": "RecaptchaV2TaskProxyless",
    "websiteURL": "https://example.com",
    "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
  }
}

CaptchaAI Gửi (tham số biểu mẫu)

POST https://ocr.captchaai.com/in.php
key=YOUR_API_KEY&method=userrecaptcha&googlekey=6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-&pageurl=https://example.com&json=1

Dịch tham số

Tiếp theoTrường Captcha Trường CaptchaAI Ghi chú
clientKey key Khóa API
task.type method Xem ánh xạ loại bên dưới
task.websiteURL pageurl URL trang mục tiêu
task.websiteKey googlekey hoặc sitekey Khóa trang web cho mã thông báo CAPTCHA
task.recaptchaDataSValue data-s tham số dữ liệu reCAPTCHA
task.isInvisible invisible=1 Cờ reCAPTCHA vô hình
task.pageAction action Hành động reCAPTCHA v3
taskId id ID task/captcha để bỏ phiếu

Ánh xạ loại nhiệm vụ

Tiếp theoLoại Captcha Phương thức CaptchaAI + Thông số
RecaptchaV2TaskProxyless method=userrecaptcha
RecaptchaV2Task method=userrecaptcha + proxy, proxytype
HCaptchaTaskProxyless method=hcaptcha
HCaptchaTask method=hcaptcha + proxy, proxytype
ImageToTextTask method=base64 + body
TurnstileTaskProxyless method=turnstile

Di chuyển mã

Python — Trước (NextCaptcha)

import requests
import time

CLIENT_KEY = "your_nextcaptcha_key"
BASE_URL = "https://api.nextcaptcha.com"

def solve_recaptcha_v2(sitekey, pageurl):
    # Submit
    resp = requests.post(f"{BASE_URL}/createTask", json={
        "clientKey": CLIENT_KEY,
        "task": {
            "type": "RecaptchaV2TaskProxyless",
            "websiteURL": pageurl,
            "websiteKey": sitekey
        }
    })
    data = resp.json()
    if data.get("errorId") != 0:
        return {"error": data.get("errorDescription")}

    task_id = data["taskId"]

    # Poll
    for _ in range(60):
        time.sleep(5)
        result = requests.post(f"{BASE_URL}/getTaskResult", json={
            "clientKey": CLIENT_KEY,
            "taskId": task_id
        }).json()
        if result.get("status") == "ready":
            return {"solution": result["solution"]["gRecaptchaResponse"]}
        if result.get("errorId") != 0:
            return {"error": result.get("errorDescription")}

    return {"error": "TIMEOUT"}

Python - Sau (CaptchaAI)

import os
import time
import requests

API_KEY = os.environ["CAPTCHAAI_API_KEY"]

def solve_recaptcha_v2(sitekey, pageurl):
    # Submit — different endpoint and format
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "userrecaptcha",
        "googlekey": sitekey,
        "pageurl": pageurl,
        "json": 1
    })
    data = resp.json()
    if data.get("status") != 1:
        return {"error": data.get("request")}

    captcha_id = data["request"]

    # Poll — GET instead of POST, different response format
    for _ in range(60):
        time.sleep(5)
        result = requests.get("https://ocr.captchaai.com/res.php", params={
            "key": API_KEY,
            "action": "get",
            "id": captcha_id,
            "json": 1
        }).json()
        if result.get("status") == 1:
            return {"solution": result["request"]}
        if result.get("request") != "CAPCHA_NOT_READY":
            return {"error": result.get("request")}

    return {"error": "TIMEOUT"}

JavaScript — Trước (NextCaptcha)

const axios = require("axios");
const CLIENT_KEY = "your_nextcaptcha_key";
const BASE_URL = "https://api.nextcaptcha.com";

async function solveRecaptchaV2(sitekey, pageurl) {
  const submit = await axios.post(`${BASE_URL}/createTask`, {
    clientKey: CLIENT_KEY,
    task: {
      type: "RecaptchaV2TaskProxyless",
      websiteURL: pageurl,
      websiteKey: sitekey,
    },
  });
  if (submit.data.errorId !== 0) return { error: submit.data.errorDescription };

  const taskId = submit.data.taskId;

  for (let i = 0; i < 60; i++) {
    await new Promise((r) => setTimeout(r, 5000));
    const poll = await axios.post(`${BASE_URL}/getTaskResult`, {
      clientKey: CLIENT_KEY,
      taskId,
    });
    if (poll.data.status === "ready") return { solution: poll.data.solution.gRecaptchaResponse };
    if (poll.data.errorId !== 0) return { error: poll.data.errorDescription };
  }
  return { error: "TIMEOUT" };
}

JavaScript — Sau (CaptchaAI)

const axios = require("axios");
const API_KEY = process.env.CAPTCHAAI_API_KEY;

async function solveRecaptchaV2(sitekey, pageurl) {
  const submit = await axios.post("https://ocr.captchaai.com/in.php", null, {
    params: { key: API_KEY, method: "userrecaptcha", googlekey: sitekey, pageurl, json: 1 },
  });
  if (submit.data.status !== 1) return { error: submit.data.request };

  const captchaId = submit.data.request;

  for (let i = 0; i < 60; i++) {
    await new Promise((r) => setTimeout(r, 5000));
    const poll = await axios.get("https://ocr.captchaai.com/res.php", {
      params: { key: API_KEY, action: "get", id: captchaId, json: 1 },
    });
    if (poll.data.status === 1) return { solution: poll.data.request };
    if (poll.data.request !== "CAPCHA_NOT_READY") return { error: poll.data.request };
  }
  return { error: "TIMEOUT" };
}

Sự khác biệt về định dạng phản hồi

Gửi phản hồi

trường Tiếp theoCaptcha CaptchaAI
Kiểm tra thành công errorId === 0 status === 1
ID nhiệm vụ taskId (số nguyên) request (chuỗi)
Thông báo lỗi errorDescription request (chuỗi mã lỗi)

Phản hồi thăm dò ý kiến

trường Tiếp theoCaptcha CaptchaAI
Kiểm tra sẵn sàng status === "ready" status === 1
Chưa sẵn sàng status === "processing" request === "CAPCHA_NOT_READY"
Giải pháp solution.gRecaptchaResponse request
Lỗi errorDescription request (mã lỗi)

Danh sách kiểm tra di chuyển

Bước Trạng thái
Tạo tài khoản CaptchaAI và nạp tiền
Ánh xạ tất cả các loại createTask sang các phương thức CaptchaAI
Thay thế clientKey bằng khóa API CaptchaAI
Cập nhật nội dung gửi từ nội dung JSON POST thành biểu mẫu POST
Cập nhật cuộc thăm dò từ POST thành GET với thông số truy vấn
Cập nhật phân tích cú pháp phản hồi (định dạng status/request)
Chạy thử nghiệm so sánh song song
Cắt giảm lưu lượng sản xuất

Khắc phục sự cố

Vấn đề Nguyên nhân Cách xử lý
ERROR_KEY_DOES_NOT_EXIST Sử dụng NextCaptcha clientKey Thay thế bằng khóa API CaptchaAI
Ngắt phân tích phản hồi Cấu trúc JSON khác nhau Cập nhật để kiểm tra các trường status (số nguyên) và request
ERROR_WRONG_USER_KEY Khóa API không đúng định dạng Xác minh định dạng khóa từ bảng điều khiển CaptchaAI
Các loại nhiệm vụ không được công nhận Sử dụng tên loại NextCaptcha Ánh xạ tới các giá trị CaptchaAI method (xem bảng trên)

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

NextCaptcha sử dụng JSON POST cho mọi thứ. CaptchaAI có yêu cầu dữ liệu được mã hóa biểu mẫu không?

CaptchaAI chấp nhận cả yêu cầu được mã hóa biểu mẫu (application/x-www-form-urlencoded) và JSON. Điểm cuối in.php hoạt động với dữ liệu biểu mẫu và việc bỏ phiếu sử dụng các tham số GET đơn giản.

Làm cách nào để xử lý các tác vụ proxy trong quá trình di chuyển?

Trong NextCaptcha, tác vụ proxy sử dụng tên loại như RecaptchaV2Task. Trong CaptchaAI, thêm tham số proxy=user:pass@host:portproxytype=HTTP vào cùng một phương thức.

Còn hỗ trợ callback/webhook thì sao?

CaptchaAI hỗ trợ tham số pingback - cung cấp URL và CaptchaAI sẽ ĐĂNG kết quả khi sẵn sàng, tương tự như chức năng gọi lại của NextCaptcha.

Các bước tiếp theo

Nhận thời gian giải quyết nhanh hơn với CaptchaAI —tạo tài khoản của bạnvà chuyển đổi sự tích hợp của bạn trong vài phút.

Hướng dẫn liên quan:

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