Tutoriales de API

CAPTCHA personalizados: cómo enviar desafíos inusuales a CaptchaAI

No todos los CAPTCHA son reCAPTCHA o imágenes de texto estándar. Los CAPTCHA personalizados requieren enfoques creativos para la extracción y el envío de parámetros.


Identificación de CAPTCHA personalizados

Tipo Características Enfoque
CAPTCHA slider Arrastrar a la posición Captura de pantalla como imagen, con instrucciones de texto
Puzzle (rompecabezas) Arrastra la pieza para encajarla Asignable a resolución estilo GeeTest
CAPTCHA de audio Escuchar y transcribir Envía el archivo de audio
Rotación de imagen Girar hasta orientación correcta Captura de pantalla + instrucciones
Selección en orden Hacer clic en elementos en secuencia Usa el enfoque de cuadrícula de imágenes
Ecuación matemática Resolver aritmética Usa el parámetro calc=1
Widget interactivo personalizado Widget JS específico del sitio Captura de pantalla + instrucciones de texto

Envío de imágenes personalizadas con instrucciones

Para cualquier CAPTCHA visual, haz una captura de pantalla y proporciona instrucciones:

import requests
import base64
import time
import os

API_KEY = os.environ["CAPTCHAAI_API_KEY"]


def solve_custom_captcha(image_b64, instructions):
    """Solve any visual CAPTCHA using image + text instructions."""
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": API_KEY,
        "method": "base64",
        "body": image_b64,
        "textinstructions": instructions,
        "json": 1,
    }, timeout=30)

    result = resp.json()
    if result.get("status") != 1:
        raise RuntimeError(result.get("request"))

    task_id = result["request"]

    time.sleep(10)
    for _ in range(30):
        resp = requests.get("https://ocr.captchaai.com/res.php", params={
            "key": API_KEY, "action": "get",
            "id": task_id, "json": 1,
        }, timeout=15)
        data = resp.json()
        if data.get("status") == 1:
            return data["request"]
        if data["request"] != "CAPCHA_NOT_READY":
            raise RuntimeError(data["request"])
        time.sleep(5)

    raise TimeoutError("Solve timeout")

CAPTCHA de posición del slider

CAPTCHA que requieren arrastrar un slider a una posición específica:

# slider_captcha.py
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains


def solve_slider_captcha(driver, captcha_selector):
    """Screenshot slider CAPTCHA and solve via CaptchaAI."""
    captcha = driver.find_element(By.CSS_SELECTOR, captcha_selector)
    image_b64 = captcha.screenshot_as_base64

    result = solve_custom_captcha(
        image_b64,
        "What pixel position should the slider be dragged to? "
        "Return only the X offset number."
    )

    try:
        offset = int(result)
    except ValueError:
        return False

    # Drag slider to position
    slider = driver.find_element(By.CSS_SELECTOR, ".slider-handle")
    ActionChains(driver).click_and_hold(slider).move_by_offset(offset, 0).release().perform()

    return True

CAPTCHA de rotación

CAPTCHA donde se debe rotar una imagen a la orientación correcta:

# rotation_captcha.py


def solve_rotation_captcha(driver, captcha_selector):
    """Solve rotation CAPTCHA."""
    captcha = driver.find_element(By.CSS_SELECTOR, captcha_selector)
    image_b64 = captcha.screenshot_as_base64

    result = solve_custom_captcha(
        image_b64,
        "How many degrees should this image be rotated clockwise "
        "to be in the correct upright orientation? Return only the number."
    )

    try:
        degrees = int(result)
    except ValueError:
        return False

    # Click rotation button the correct number of times
    rotate_btn = driver.find_element(By.CSS_SELECTOR, ".rotate-button")
    clicks = degrees // 90  # Each click rotates 90 degrees

    for _ in range(clicks):
        rotate_btn.click()
        time.sleep(0.3)

    return True

CAPTCHA de orden de selección

CAPTCHA donde se debe hacer clic en elementos en un orden específico:

# order_captcha.py


def solve_order_captcha(driver, captcha_selector, item_selector):
    """Solve click-in-order CAPTCHA."""
    captcha = driver.find_element(By.CSS_SELECTOR, captcha_selector)
    image_b64 = captcha.screenshot_as_base64

    result = solve_custom_captcha(
        image_b64,
        "What is the correct order? Return as comma-separated "
        "numbers (1-indexed) representing positions left-to-right, top-to-bottom."
    )

    # Parse order
    try:
        order = [int(x.strip()) for x in result.split(",")]
    except ValueError:
        return False

    # Click items in order
    items = driver.find_elements(By.CSS_SELECTOR, item_selector)
    for idx in order:
        if 1 <= idx <= len(items):
            items[idx - 1].click()
            time.sleep(0.5)

    return True

CAPTCHA de audio

Algunos sitios ofrecen alternativas de audio:

# audio_captcha.py
import requests


def solve_audio_captcha(audio_url):
    """Download and solve an audio CAPTCHA."""
    # Download audio
    resp = requests.get(audio_url, timeout=30)
    audio_b64 = base64.b64encode(resp.content).decode("ascii")

    # Submit as image with instructions
    # CaptchaAI may support audio via the base64 method
    result = solve_custom_captcha(
        audio_b64,
        "This is an audio CAPTCHA. Transcribe the spoken characters."
    )
    return result

CAPTCHA de widgets personalizados

Para widgets CAPTCHA completamente personalizados:

# custom_widget.py
from selenium import webdriver
from selenium.webdriver.common.by import By


def handle_custom_widget(driver, widget_selector):
    """Handle an unknown custom CAPTCHA widget."""

    # Step 1: Screenshot the entire widget
    widget = driver.find_element(By.CSS_SELECTOR, widget_selector)
    image_b64 = widget.screenshot_as_base64

    # Step 2: Get any visible instructions
    try:
        instructions_el = widget.find_element(By.CSS_SELECTOR, ".instructions, .prompt, p")
        visible_instructions = instructions_el.text
    except Exception:
        visible_instructions = "Solve this CAPTCHA"

    # Step 3: Submit with descriptive instructions
    result = solve_custom_captcha(
        image_b64,
        f"CAPTCHA instructions: {visible_instructions}. "
        f"Return the answer text."
    )

    # Step 4: Try to submit result
    try:
        input_el = widget.find_element(By.CSS_SELECTOR, "input")
        input_el.clear()
        input_el.send_keys(result)
    except Exception:
        # No input — try clicking based on result
        driver.execute_script("""
            var input = document.querySelector('input[name*="captcha"]');
            if (input) input.value = arguments[0];
        """, result)

    return result

Detección de tipo CAPTCHA

# detector.py
import re


def detect_captcha_type(page_html):
    """Detect which CAPTCHA type is on a page."""
    checks = {
        "recaptcha_v2": r'data-sitekey.*g-recaptcha',
        "recaptcha_v3": r'recaptcha/api\.js\?render=',
        "turnstile": r'cf-turnstile|challenges\.cloudflare\.com/turnstile',
        "geetest": r'gt\b.*challenge|geetest',
        "bls": r'method.*bls|bls-captcha',
        "image_text": r'captcha.*\.(png|jpg|gif|jpeg)',
        "slider": r'slider.*captcha|slide.*verify',
        "audio": r'audio.*captcha|captcha.*audio',
    }

    detected = []
    for captcha_type, pattern in checks.items():
        if re.search(pattern, page_html, re.IGNORECASE):
            detected.append(captcha_type)

    return detected if detected else ["unknown"]

Solución de problemas

Problema Causa Solución
ERROR_CAPTCHA_UNSOLVABLE Imagen poco clara o instrucciones vagas Mejora la calidad de las capturas de pantalla y las instrucciones
Formato de respuesta incorrecto El solucionador devolvió una descripción en lugar del valor Sé específico: “Devuelve solo el número”
Widget personalizado no capturado Elemento fuera de la ventana gráfica Desplázate al elemento antes de la captura de pantalla
La interacción falla Coordenadas de clic incorrectas Mapea cuidadosamente la solución a los elementos reales de la UI

Preguntas frecuentes

¿Puede CaptchaAI resolver cualquier tipo de CAPTCHA?

CaptchaAI admite más de 27.500 tipos CAPTCHA de forma nativa. Para CAPTCHA personalizados verdaderamente novedosos, el enfoque de instrucciones de imagen + texto proporciona la mejor cobertura.

¿Qué pasa si el CAPTCHA personalizado cambia con frecuencia?

Utilice la función de detección de tipo para identificar el desafío actual y dirigirlo al solucionador adecuado.

¿Cómo obtengo soporte para un nuevo tipo CAPTCHA?

Póngase en contacto con el soporte de CaptchaAI con imágenes de ejemplo y la URL del sitio. Se pueden agregar nuevos tipos a la plataforma.


Guías relacionadas

  • Estrategias de resolución de personajes múltiples
  • Mejores prácticas de codificación Base64

Los comentarios están deshabilitados para este artículo.