BLS CAPTCHA é um desafio personalizado baseado em imagem usado nos sistemas de marcação de vistos BLS International. Ele exibe várias imagens e pede ao usuário para selecionar imagens específicas com base em instruções de texto – semelhante à grade reCAPTCHA, mas com imagens distintas e instruções personalizadas.
Este guia cobre a extração de imagens, seu envio para CaptchaAI e o uso da solução para preencher formulários BLS.
Requisitos
| Artigo | Valor |
|---|---|
| Chave de API CaptchaAI | Decaptchaai.com |
| Imagens BLS CAPTCHA | Codificado em Base64 da página |
| Texto de instruções | O texto informando quais imagens selecionar |
| Idioma | Python 3.7+ ou Node.js 14+ |
Etapa 1: extraia imagens e instruções da página
BLS CAPTCHA normalmente mostra de 3 a 9 imagens com uma instrução de texto como "Selecionar todas as imagens com um carro".
Usando Selênio
from selenium import webdriver
from selenium.webdriver.common.by import By
import base64
import requests as req
driver = webdriver.Chrome()
driver.get("https://blsitalypakistan.com/appointment")
# Get instruction text
instruction = driver.find_element(By.CSS_SELECTOR, ".captcha-instruction").text
print(f"Instruction: {instruction}")
# Get all captcha images as base64
images = {}
captcha_imgs = driver.find_elements(By.CSS_SELECTOR, ".captcha-image img")
for i, img in enumerate(captcha_imgs, 1):
src = img.get_attribute("src")
if src.startswith("data:image"):
# Already base64
images[f"image_base64_{i}"] = src.split(",")[1]
else:
# Download and encode
img_data = req.get(src).content
images[f"image_base64_{i}"] = base64.b64encode(img_data).decode()
Usando o Puppeteer
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
await page.goto('https://blsitalypakistan.com/appointment');
// Get instruction
const instruction = await page.$eval('.captcha-instruction', el => el.textContent);
// Get images as base64
const images = await page.$$eval('.captcha-image img', imgs =>
imgs.map((img, i) => ({
key: `image_base64_${i + 1}`,
value: img.src.startsWith('data:') ? img.src.split(',')[1] : null
}))
);
Etapa 2: enviar para CaptchaAI
Envie o texto da instrução e todas as imagens para o solucionador BLS.
Pitão
import requests
import time
API_KEY = "YOUR_API_KEY"
payload = {
"key": API_KEY,
"method": "bls",
"instructions": instruction,
"json": 1
}
# Add each image (up to 9)
for key, value in images.items():
payload[key] = value
response = requests.post("https://ocr.captchaai.com/in.php", data=payload)
data = response.json()
if data.get("status") != 1:
raise Exception(f"Submit error: {data.get('request')}")
task_id = data["request"]
print(f"Task submitted: {task_id}")
Node.js
const axios = require('axios');
const FormData = require('form-data');
async function submitBLS(instruction, images) {
const params = {
key: 'YOUR_API_KEY',
method: 'bls',
instructions: instruction,
json: 1,
...Object.fromEntries(images.map(img => [img.key, img.value]))
};
const { data } = await axios.post('https://ocr.captchaai.com/in.php', null, { params });
if (data.status !== 1) throw new Error(data.request);
return data.request;
}
Passo 3: Pesquise a solução
A solução retorna os índices das imagens corretas.
Pitão
def get_bls_solution(task_id):
for _ in range(30):
time.sleep(5)
result = requests.get("https://ocr.captchaai.com/res.php", params={
"key": API_KEY,
"action": "get",
"id": task_id,
"json": 1
}).json()
if result.get("status") == 1:
return result["request"] # e.g., "1,3,5" (image indices)
if result.get("request") != "CAPCHA_NOT_READY":
raise Exception(f"Error: {result.get('request')}")
raise Exception("Timeout")
solution = get_bls_solution(task_id)
print(f"Select images: {solution}") # e.g., "1,3,5"
Etapa 4: clique nas imagens corretas
Use os índices retornados para clicar nas imagens correspondentes na página:
# Parse the solution indices
selected = [int(i) for i in solution.split(",")]
# Click each correct image
captcha_imgs = driver.find_elements(By.CSS_SELECTOR, ".captcha-image img")
for idx in selected:
captcha_imgs[idx - 1].click() # Convert 1-based to 0-based
time.sleep(0.3) # Small delay between clicks
# Submit the form
driver.find_element(By.CSS_SELECTOR, ".captcha-submit").click()
Exemplo completo de Python
import requests
import time
import base64
from selenium import webdriver
from selenium.webdriver.common.by import By
API_KEY = "YOUR_API_KEY"
driver = webdriver.Chrome()
driver.get("https://blsitalypakistan.com/appointment")
# 1. Extract instruction and images
instruction = driver.find_element(By.CSS_SELECTOR, ".captcha-instruction").text
captcha_imgs = driver.find_elements(By.CSS_SELECTOR, ".captcha-image img")
payload = {"key": API_KEY, "method": "bls", "instructions": instruction, "json": 1}
for i, img in enumerate(captcha_imgs, 1):
src = img.get_attribute("src")
if src.startswith("data:image"):
payload[f"image_base64_{i}"] = src.split(",")[1]
# 2. Submit to CaptchaAI
resp = requests.post("https://ocr.captchaai.com/in.php", data=payload).json()
task_id = resp["request"]
# 3. Poll for solution
for _ in range(30):
time.sleep(5)
result = requests.get("https://ocr.captchaai.com/res.php", params={
"key": API_KEY, "action": "get", "id": task_id, "json": 1
}).json()
if result.get("status") == 1:
selected = [int(i) for i in result["request"].split(",")]
break
# 4. Click correct images and submit
for idx in selected:
captcha_imgs[idx - 1].click()
time.sleep(0.3)
driver.find_element(By.CSS_SELECTOR, ".captcha-submit").click()
print("CAPTCHA solved!")
driver.quit()
Solução de problemas
| Erro | Causa | Correção |
|---|---|---|
ERROR_BAD_PARAMETERS |
Instruções ou imagens ausentes | Inclua as instruções de texto e pelo menos uma imagem |
ERROR_CAPTCHA_UNSOLVABLE |
Imagens muito desfocadas ou irreconhecíveis | Capture imagens de maior qualidade; garantir que a codificação base64 esteja correta |
| Imagens erradas selecionadas | Ordem de imagem incorreta | Certifique-se de que as imagens sejam numeradas na ordem de exibição correta |
| Solução rejeitada | Imagens alteradas após a extração | Extraia imagens e envie imediatamente |
Exemplo executável completo
Precisa de um projeto funcional completo com configuração de ambiente, pesquisas, novas tentativas e tratamento de erros?
Veja o exemplo executável completo no GitHub →
Perguntas frequentes
Quantas imagens BLS CAPTCHA mostra?
Normalmente de 3 a 9 imagens. O número varia de acordo com a página e a sessão.
Em que formato as imagens devem estar?
PNG ou JPEG codificado em Base64. Remova o prefixo data:image/...;base64, antes de enviar.
Quanto tempo leva a resolução de BLS CAPTCHA?
15–30 segundos normalmente. Os desafios de reconhecimento de imagem demoram mais do que os CAPTCHAs baseados em texto.
Posso resolver BLS CAPTCHA sem Selenium?
Sim, se você puder extrair as imagens e instruções por meio de solicitações HTTP. A API CaptchaAI precisa apenas de imagens base64 e texto de instruções.