Tutorials

BLS CAPTCHA: Tìm hiểu mã hướng dẫn và giải quyết

BLS CAPTCHA hiển thị lưới hình ảnh 3×3 với mã hướng dẫn bằng số. Người dùng phải chọn các ô phù hợp với hướng dẫn. CaptchaAI giải BLS CAPTCHA với độ chính xác 100% - hướng dẫn này trình bày cách trích xuất lưới, đọc mã hướng dẫn và gửi mọi thứ tới API.


Cách hoạt động của BLS CAPTCHA

BLS CAPTCHA hiển thị:

  1. Một lưới 3×3 chứa 9 ô hình ảnh
  2. Mã lệnh số (ví dụ: 664, 123, 546) chỉ định ô nào cần chọn
  3. Các ô được đánh số từ trái sang phải, từ trên xuống dưới:
1  2  3
4  5  6
7  8  9

Mã lệnh cho người giải biết mẫu nào cần tìm. Phản hồi là một mảng các chỉ số ô (1–9) khớp với nhau.


Bước 1: Trích xuất hình ảnh lưới và mã lệnh

Python (Selen)

import base64
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://example.com/bls-protected-page")

# Find the grid container
grid_cells = driver.find_elements(By.CSS_SELECTOR, ".captcha-grid img")

images = []
for cell in grid_cells:
    src = cell.get_attribute("src")
    if src.startswith("data:image"):
        images.append(src)
    else:
        # Download and convert to base64
        import requests
        img_data = requests.get(src).content
        b64 = base64.b64encode(img_data).decode()
        images.append(f"data:image/png;base64,{b64}")

# Extract the instruction code
instruction_el = driver.find_element(By.CSS_SELECTOR, ".captcha-instruction")
instruction_code = instruction_el.text.strip()
# e.g., "664" or parsed from "Select all boxes with number 664"

import re
code_match = re.search(r'(\d{3,})', instruction_code)
instruction = code_match.group(1) if code_match else instruction_code

print(f"Instruction: {instruction}")
print(f"Images extracted: {len(images)}")

JavaScript (Puppeteer)

const puppeteer = require('puppeteer');

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

// Extract grid images as base64
const images = await page.evaluate(() => {
  const cells = document.querySelectorAll('.captcha-grid img');
  return Array.from(cells).map(img => {
    const canvas = document.createElement('canvas');
    canvas.width = img.naturalWidth;
    canvas.height = img.naturalHeight;
    canvas.getContext('2d').drawImage(img, 0, 0);
    return canvas.toDataURL('image/png');
  });
});

// Extract instruction code
const instruction = await page.evaluate(() => {
  const el = document.querySelector('.captcha-instruction');
  const match = el.textContent.match(/(\d{3,})/);
  return match ? match[1] : el.textContent.trim();
});

console.log(`Instruction: ${instruction}, Images: ${images.length}`);

Bước 2: Gửi tới CaptchaAI

Bộ giải BLS yêu cầu method=bls, mã instructions và tất cả 9 hình ảnh dưới dạng image_base64_1 đến image_base64_9.

Python

import requests
import time
import json

API_KEY = "YOUR_API_KEY"

# Prepare submission data
data = {
    "key": API_KEY,
    "method": "bls",
    "instructions": instruction,
    "json": "1",
}

# Add all 9 images
files = {}
for i, img in enumerate(images):
    files[f"image_base64_{i+1}"] = (None, img)

# Submit
resp = requests.post(
    "https://ocr.captchaai.com/in.php",
    data=data,
    files=files
).json()

if resp["status"] != 1:
    raise Exception(f"Submit error: {resp['request']}")

task_id = resp["request"]
print(f"Task ID: {task_id}")

# Poll for result
for _ in range(20):
    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["status"] == 1:
        solution = json.loads(result["request"])
        print(f"Selected cells: {solution}")  # e.g., [1, 4, 7, 8]
        break
    if result["request"] != "CAPCHA_NOT_READY":
        raise Exception(f"Error: {result['request']}")

JavaScript

const axios = require('axios');
const FormData = require('form-data');

const form = new FormData();
form.append('key', 'YOUR_API_KEY');
form.append('method', 'bls');
form.append('instructions', instruction);
form.append('json', '1');

images.forEach((img, i) => {
  form.append(`image_base64_${i + 1}`, img);
});

const submit = await axios.post('https://ocr.captchaai.com/in.php', form, {
  headers: form.getHeaders(),
});
const taskId = submit.data.request;

// Poll
let solution = null;
for (let i = 0; i < 20; i++) {
  await new Promise(r => setTimeout(r, 5000));
  const poll = await axios.get('https://ocr.captchaai.com/res.php', {
    params: { key: 'YOUR_API_KEY', action: 'get', id: taskId, json: 1 }
  });
  if (poll.data.status === 1) {
    solution = JSON.parse(poll.data.request);
    break;
  }
}
console.log('Selected cells:', solution); // e.g., [2, 4, 7]

Bước 3: Bấm vào các ô đã giải quyết

# Selenium — click the cells returned by CaptchaAI
grid_cells = driver.find_elements(By.CSS_SELECTOR, ".captcha-grid .cell")

for cell_index in solution:
    # cell_index is 1-based
    grid_cells[cell_index - 1].click()

# Submit the form
submit_btn = driver.find_element(By.CSS_SELECTOR, ".captcha-submit")
submit_btn.click()
// Puppeteer
const cells = await page.$$('.captcha-grid .cell');
for (const idx of solution) {
  await cells[idx - 1].click();
}
await page.click('.captcha-submit');

Hoàn thành quy trình làm việc

def solve_bls_captcha(driver, api_key):
    """Extract, solve, and submit a BLS CAPTCHA."""
    import base64, requests, time, json, re

    # 1. Extract images
    grid_cells = driver.find_elements(By.CSS_SELECTOR, ".captcha-grid img")
    images = []
    for cell in grid_cells:
        src = cell.get_attribute("src")
        if src.startswith("data:image"):
            images.append(src)
        else:
            img_data = requests.get(src).content
            b64 = base64.b64encode(img_data).decode()
            images.append(f"data:image/png;base64,{b64}")

    # 2. Extract instruction
    el = driver.find_element(By.CSS_SELECTOR, ".captcha-instruction")
    match = re.search(r'(\d{3,})', el.text)
    instruction = match.group(1)

    # 3. Submit to CaptchaAI
    data = {"key": api_key, "method": "bls", "instructions": instruction, "json": "1"}
    files = {f"image_base64_{i+1}": (None, img) for i, img in enumerate(images)}
    resp = requests.post("https://ocr.captchaai.com/in.php", data=data, files=files).json()
    task_id = resp["request"]

    # 4. Poll
    for _ in range(20):
        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["status"] == 1:
            solution = json.loads(result["request"])
            break

    # 5. Click cells
    clickable = driver.find_elements(By.CSS_SELECTOR, ".captcha-grid .cell")
    for idx in solution:
        clickable[idx - 1].click()

    return solution

Khắc phục sự cố

Vấn đề Nguyên nhân Cách xử lý
ERROR_BAD_PARAMETERS Thiếu hình ảnh hoặc không có hướng dẫn Đảm bảo tất cả 9 hình ảnh đều là URI dữ liệu base64 hợp lệ
Đã chọn sai ô Ánh xạ ô tới chỉ mục không chính xác Xác minh các ô được đánh số từ 1-9 từ trái sang phải, từ trên xuống dưới
Hình ảnh không tải Hạn chế xuất xứ chéo Tải xuống hình ảnh phía máy chủ và chuyển đổi sang base64
Mã hướng dẫn trống Hướng dẫn ẩn trong hình ảnh Trích xuất văn bản hướng dẫn hoặc OCR hình ảnh hướng dẫn

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

Mã hướng dẫn BLS có nghĩa là gì?

Mã hướng dẫn (ví dụ: "664") cho CAPTCHA biết ô nào chứa nội dung phù hợp. CaptchaAI phân tích nó - bạn không cần phải tự mình giải thích mã.

CaptchaAI cho BLS chính xác đến mức nào?

CaptchaAI báo cáo độ chính xác 100% cho BLS CAPTCHA.


Giải BLS CAPTCHA bằng CaptchaAI — chính xác 100%

Nhận khóa API của bạn tạicaptchaai.com.


Hướng dẫn liên quan

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

Postagens relacionadas

DevOps & Scaling Xây dựng giải quyết CAPTCHA theo sự kiện bằng AWS SNS và CaptchaAI
Hướng dẫn Dev Ops xây dựng giải pháp giải quyết tình huống CAPTCHA bằng AWS SNS và Captcha AI, với các quyết định về kiến ​​trúc, các cân nhắc vận hành và mô hì...

Hướng dẫn Dev Ops xây dựng giải pháp giải quyết tình huống CAPTCHA bằng AWS SNS và Captcha AI, với các quyết đ...

Apr 25, 2026
Troubleshooting CAPTCHA tự động hóa trình duyệt không thành công nhưng API vẫn hoạt động: Hướng dẫn gỡ lỗi
Hướng dẫn thực hành về trình duyệt tự động hóa CAPTCHA không thành công nhưng API vẫn hoạt động: Hướng dẫn gỡ lỗi, với các nguyên nhân phổ biến, các bước chẩn đ...

Hướng dẫn thực hành về trình duyệt tự động hóa CAPTCHA không thành công nhưng API vẫn hoạt động: Hướng dẫn gỡ...

Apr 29, 2026
Tutorials Xây dựng quy trình thử nghiệm tự động với CaptchaAI
Hướng dẫn từng bước để xây dựng quy trình thử nghiệm tự động với Captcha AI, với các ví dụ có thể sử dụng lại trực tiếp và quy trình làm việc Captcha AI rõ ràng...

Hướng dẫn từng bước để xây dựng quy trình thử nghiệm tự động với Captcha AI, với các ví dụ có thể sử dụng lại...

Apr 30, 2026