Tutoriais de API

Resolva BLS CAPTCHA com Node.js e CaptchaAI

BLS CAPTCHA apresenta uma grade 3×3 de imagens com um código de instrução numérico especificando quais células selecionar. Este tutorial mostra como resolver BLS CAPTCHAs de Node.js usando oCaptchaAIAPI.


Pré-requisitos

Artigo Valor
Chave de API CaptchaAI Decaptchaai.com
Node.js 14+
Biblioteca axios (npm install axios)

Como funciona o BLS CAPTCHA

Uma grade 3×3 numerada da esquerda para a direita, de cima para baixo:

1 | 2 | 3
---------
4 | 5 | 6
---------
7 | 8 | 9

Uma instrução numérica (por exemplo, "664") especifica o que selecionar. CaptchaAI retorna os índices das células correspondentes.


Etapa 1: extrair imagens da grade

const axios = require('axios');
const puppeteer = require('puppeteer');

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com/bls-form');

// Get instruction code
const instruction = await page.$eval('.bls-instruction', (el) => el.textContent.trim());

// Get all 9 cell image URLs and convert to base64
const cellImages = await page.$$eval('.bls-grid img', (imgs) =>
  imgs.map((img) => img.src)
);

const images = [];
for (const src of cellImages) {
  if (src.startsWith('data:')) {
    images.push(src);
  } else {
    const { data } = await axios.get(src, { responseType: 'arraybuffer' });
    const b64 = Buffer.from(data).toString('base64');
    images.push(`data:image/png;base64,${b64}`);
  }
}

Etapa 2: enviar para CaptchaAI

const API_KEY = 'YOUR_API_KEY';
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

const params = new URLSearchParams({
  key: API_KEY,
  method: 'bls',
  instructions: instruction,
  json: '1',
});

// Add all 9 images
images.forEach((img, i) => {
  params.append(`image_base64_${i + 1}`, img);
});

const { data: submitData } = await axios.post(
  'https://ocr.captchaai.com/in.php',
  params.toString()
);

if (submitData.status !== 1) throw new Error(submitData.request);
const taskId = submitData.request;
console.log(`Task submitted: ${taskId}`);

Passo 3: Pesquise a solução

await sleep(5000);

let selectedCells;
for (let i = 0; i < 30; i++) {
  const { data: pollData } = await axios.get('https://ocr.captchaai.com/res.php', {
    params: { key: API_KEY, action: 'get', id: taskId, json: 1 },
  });

  if (pollData.status === 1) {
    selectedCells = JSON.parse(pollData.request);
    console.log('Selected cells:', selectedCells);
    break;
  }
  if (pollData.request !== 'CAPCHA_NOT_READY') {
    throw new Error(pollData.request);
  }
  await sleep(5000);
}

Etapa 4: clique nas células corretas

// Click each identified cell
const gridCells = await page.$$('.bls-grid img');
for (const cellNum of selectedCells) {
  await gridCells[cellNum - 1].click();
}

// Submit the form
await page.click('.bls-submit');
console.log(`Solved: clicked cells ${JSON.stringify(selectedCells)}`);
await browser.close();

Resultado esperado:

Selected cells: [1, 4, 7, 8]
Solved: clicked cells [1,4,7,8]

Erros comuns

Erro Causa Correção
ERROR_BAD_PARAMETERS Imagens ou instruções ausentes Envie todas as 9 imagens e o código de instrução
CAPCHA_NOT_READY Ainda processando Continue pesquisando a cada 5 segundos
ERROR_ZERO_BALANCE Sem fundos Recarregue sua conta CaptchaAI

Perguntas frequentes

O BLS CAPTCHA suporta grades 4×4?

BLS CAPTCHA usa grades 3×3 (9 células). Para grades 4×4, use o método Grid Image.

Quão rápido é a resolução do BLS?

Normalmente de 5 a 15 segundos.

Posso usar o Playwright em vez do Puppeteer?

Sim. A interação da API é a mesma – basta alterar as chamadas de automação do navegador.


Guias relacionados


Comece a resolver BLS CAPTCHAs com CaptchaAI →

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