Los sitios web en árabe, farsi y hebreo presentan CAPTCHA con secuencias de comandos de derecha a izquierda (RTL) que desafían el OCR estándar y la inyección de texto. Los caracteres árabes se conectan de manera diferente según la posición (inicial, medial, final o formas aisladas), lo que dificulta el reconocimiento de imágenes CAPTCHA. Combinados con diseños de páginas RTL que afectan el posicionamiento de los elementos, estos sitios necesitan un manejo específico.
Desafíos CAPTCHA RTL
| Desafío | Detalle |
|---|---|
| Conexión de personaje | Las letras árabes cambian de forma según los caracteres adyacentes |
| Lectura de derecha a izquierda | El texto en CAPTCHA se lee de derecha a izquierda |
| Dirección mixta | Números y texto latino mezclados con árabe (bidireccional) |
| marcas diacríticas | Puntos y marcas encima de los caracteres /below (شاين vs ساين) |
| Diseño de página RTL | Los elementos del formulario y la ubicación del CAPTCHA difieren de LTR |
Python: CAPTCHA de imagen árabe
import requests
import base64
import time
API_KEY = "YOUR_API_KEY"
SUBMIT_URL = "https://ocr.captchaai.com/in.php"
RESULT_URL = "https://ocr.captchaai.com/res.php"
def solve_arabic_captcha(image_path: str) -> str:
"""Solve an Arabic script image CAPTCHA."""
with open(image_path, "rb") as f:
image_b64 = base64.b64encode(f.read()).decode()
resp = requests.post(SUBMIT_URL, data={
"key": API_KEY,
"method": "base64",
"body": image_b64,
"language": 2, # Non-Latin character support
"json": 1,
}, timeout=30).json()
if resp.get("status") != 1:
raise RuntimeError(f"Submit: {resp.get('request')}")
task_id = resp["request"]
for _ in range(24):
time.sleep(5)
poll = requests.get(RESULT_URL, params={
"key": API_KEY, "action": "get", "id": task_id, "json": 1,
}, timeout=15).json()
if poll.get("request") == "CAPCHA_NOT_READY":
continue
if poll.get("status") == 1:
return poll["request"]
raise RuntimeError(f"Solve: {poll.get('request')}")
raise RuntimeError("Timeout")
def solve_arabic_captcha_from_url(session: requests.Session,
captcha_url: str) -> str:
"""Download and solve an Arabic CAPTCHA from a URL."""
resp = session.get(captcha_url, timeout=15)
image_b64 = base64.b64encode(resp.content).decode()
submit = requests.post(SUBMIT_URL, data={
"key": API_KEY,
"method": "base64",
"body": image_b64,
"language": 2,
"json": 1,
}, timeout=30).json()
if submit.get("status") != 1:
raise RuntimeError(f"Submit: {submit.get('request')}")
task_id = submit["request"]
for _ in range(24):
time.sleep(5)
poll = requests.get(RESULT_URL, params={
"key": API_KEY, "action": "get", "id": task_id, "json": 1,
}, timeout=15).json()
if poll.get("request") == "CAPCHA_NOT_READY":
continue
if poll.get("status") == 1:
return poll["request"]
raise RuntimeError(f"Solve: {poll.get('request')}")
raise RuntimeError("Timeout")
# --- RTL-aware form submission ---
def submit_form_with_arabic_captcha(
form_url: str,
captcha_url: str,
form_data: dict,
captcha_field: str = "captcha",
) -> requests.Response:
"""Complete an Arabic website form with CAPTCHA."""
session = requests.Session()
session.headers.update({
"Accept-Language": "ar-SA,ar;q=0.9",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
})
# Load the form page to establish session
session.get(form_url, timeout=15)
# Solve the CAPTCHA
captcha_text = solve_arabic_captcha_from_url(session, captcha_url)
print(f"Arabic CAPTCHA solved: {captcha_text}")
# Submit with the solved text
form_data[captcha_field] = captcha_text
response = session.post(form_url, data=form_data, timeout=30)
return response
# --- Usage ---
# Simple Arabic image CAPTCHA
text = solve_arabic_captcha("arabic_captcha.png")
print(f"Arabic text: {text}")
# Form submission on Arabic site
response = submit_form_with_arabic_captcha(
form_url="https://example.sa/registration",
captcha_url="https://example.sa/captcha/generate",
form_data={
"name": "اسم المستخدم",
"email": "user@example.com",
},
)
JavaScript: árabe y RTL CAPTCHA
const API_KEY = "YOUR_API_KEY";
const SUBMIT_URL = "https://ocr.captchaai.com/in.php";
const RESULT_URL = "https://ocr.captchaai.com/res.php";
const fs = require("fs");
async function solveArabicCaptcha(imagePath) {
const imageB64 = fs.readFileSync(imagePath, "base64");
const body = new URLSearchParams({
key: API_KEY,
method: "base64",
body: imageB64,
language: "2",
json: "1",
});
const resp = await (await fetch(SUBMIT_URL, { method: "POST", body })).json();
if (resp.status !== 1) throw new Error(`Submit: ${resp.request}`);
const taskId = resp.request;
for (let i = 0; i < 24; i++) {
await new Promise((r) => setTimeout(r, 5000));
const url = `${RESULT_URL}?key=${API_KEY}&action=get&id=${taskId}&json=1`;
const poll = await (await fetch(url)).json();
if (poll.request === "CAPCHA_NOT_READY") continue;
if (poll.status === 1) return poll.request;
throw new Error(`Solve: ${poll.request}`);
}
throw new Error("Timeout");
}
// Inject CAPTCHA token into RTL page with Playwright
async function solveAndInjectRTL(page) {
// RTL pages may position the CAPTCHA differently
const captchaImg = await page.locator("img[id*='captcha'], img[class*='captcha']");
const imgSrc = await captchaImg.getAttribute("src");
// Download the image
const buffer = await (await fetch(imgSrc)).arrayBuffer();
const imageB64 = Buffer.from(buffer).toString("base64");
// Solve
const body = new URLSearchParams({
key: API_KEY, method: "base64", body: imageB64,
language: "2", json: "1",
});
const resp = await (await fetch(SUBMIT_URL, { method: "POST", body })).json();
if (resp.status !== 1) throw new Error(`Submit: ${resp.request}`);
const taskId = resp.request;
for (let i = 0; i < 24; i++) {
await new Promise((r) => setTimeout(r, 5000));
const url = `${RESULT_URL}?key=${API_KEY}&action=get&id=${taskId}&json=1`;
const poll = await (await fetch(url)).json();
if (poll.request === "CAPCHA_NOT_READY") continue;
if (poll.status === 1) {
// Fill the input — RTL input handles text direction automatically
await page.locator("input[name*='captcha']").fill(poll.request);
return poll.request;
}
throw new Error(`Solve: ${poll.request}`);
}
}
// Usage
const text = await solveArabicCaptcha("arabic_captcha.png");
console.log(`Arabic text: ${text}`);
Scripts RTL compatibles
| Script | Idiomas | Caracteres de ejemplo |
|---|---|---|
| Árabe | Árabe, urdu, pastún | عربي - أبجدية |
| Farsi/Persa | Farsi | ÙØ§Ø±Ø³ÛŒ - ØØ±ÙˆÙ |
| Hebreo | Hebreo | עברית - ×ותיות |
Solución de problemas
| Asunto | Causa | Solución |
|---|---|---|
| Texto árabe invertido en la checkout | Cliente que muestra texto RTL como LTR | Ajustar la checkout en \u202B (incrustación RTL) o usar pantalla compatible con RTL |
| Faltan signos diacríticos | Imagen de baja resolución | Utilice imágenes CAPTCHA de mayor resolución |
| Texto bidireccional (árabe+números) mezclado | Algoritmo BiDi aplicado de manera inconsistente | Manejar caracteres direccionales explícitamente con marcadores Unicode |
| El envío del formulario falla con la entrada en árabe | La codificación no coincide | Utilice charset=UTF-8 en el encabezado de tipo de contenido |
| La posición del CAPTCHA difiere de lo esperado | El diseño RTL refleja las posiciones de los elementos | Utilice selectores CSS en lugar de detección basada en posición |
Preguntas frecuentes
¿CaptchaAI maneja la escritura árabe conectada?
Sí. Los caracteres árabes se conectan cuando son adyacentes: la misma letra se ve diferente según su posición en una palabra. El solucionador Image/OCR de CaptchaAI reconoce la escritura árabe conectada, incluidas las formas de letras iniciales, medias, finales y aisladas.
¿Cómo manejo los CAPTCHA en farsi frente a los CAPTCHA en árabe?
Ambos usan la escritura árabe pero con caracteres adicionales (como Ù¾, Ú†, Ú˜, Ú¯ en farsi). Utilice language=2 para ambos. CaptchaAI reconoce automáticamente el juego de caracteres extendido.
¿Los diseños de páginas RTL afectan la detección de CAPTCHA?
Los diseños RTL reflejan la página: los formularios y CAPTCHA pueden aparecer en lados opuestos en comparación con las páginas LTR. Utilice selectores CSS o ID para ubicar elementos CAPTCHA en lugar de depender de la posición visual.
Próximos pasos
Resuelve CAPTCHA en sitios web árabes y RTL: obtén tu API key de CaptchaAI y maneja cualquier conjunto de caracteres RTL.
Guías relacionadas:
- Resolver CAPTCHA en sitios web chinos
- Configuración de idioma y localización CAPTCHA