API Tutorials

How to Solve BLS CAPTCHA Step by Step

BLS CAPTCHA is a custom image-based challenge used on BLS International visa appointment systems. It displays multiple images and asks the user to select specific ones based on text instructions — similar to reCAPTCHA grid but with distinct images and custom instructions.

This guide covers extracting images, submitting them to CaptchaAI, and using the solution to complete BLS forms.


Requirements

Item Value
CaptchaAI API key From captchaai.com
BLS CAPTCHA images Base64-encoded from the page
Instructions text The text telling which images to select
Language Python 3.7+ or Node.js 14+

Step 1: Extract images and instructions from the page

BLS CAPTCHA typically shows 3–9 images with a text instruction like "Select all images with a car."

Using Selenium

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()

Using 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
  }))
);

Step 2: Submit to CaptchaAI

Send the instruction text and all images to the BLS solver.

Python

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;
}

Step 3: Poll for the solution

The solution returns the indices of the correct images.

Python

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"

Step 4: Click the correct images

Use the returned indices to click the corresponding images on the page:

# 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()

Complete Python example

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()

Troubleshooting

Error Cause Fix
ERROR_BAD_PARAMETERS Missing instructions or images Include both the text instruction and at least one image
ERROR_CAPTCHA_UNSOLVABLE Images too blurry or unrecognizable Capture higher quality images; ensure base64 encoding is correct
Wrong images selected Incorrect image order Ensure images are numbered in the correct display order
Solution rejected Images changed after extraction Extract images and submit immediately

FAQ

How many images does BLS CAPTCHA show?

Typically 3–9 images. The number varies by page and session.

What format should images be in?

Base64-encoded PNG or JPEG. Remove the data:image/...;base64, prefix before sending.

How long does BLS CAPTCHA solving take?

15–30 seconds typically. Image recognition challenges take longer than text-based CAPTCHAs.

Can I solve BLS CAPTCHA without Selenium?

Yes, if you can extract the images and instructions via HTTP requests. The CaptchaAI API only needs the base64 images and instruction text.


Discussions (0)

No comments yet.

Related Posts

Explainers How BLS CAPTCHA Works: Grid Logic and Image Selection
Deep dive into BLS CAPTCHA grid logic — how images are arranged, how instructions map to selections, and how Captcha AI processes BLS challenges.

Deep dive into BLS CAPTCHA grid logic — how images are arranged, how instructions map to selections, and how C...

Automation BLS CAPTCHA
Apr 09, 2026
Use Cases Government Portal Automation with CAPTCHA Solving
Automate government portal interactions (visa applications, permit filings, records requests) with Captcha AI handling CAPTCHA challenges.

Automate government portal interactions (visa applications, permit filings, records requests) with Captcha AI...

Automation Python reCAPTCHA v2
Jan 30, 2026
Explainers How BLS CAPTCHA Works
Understand how BLS CAPTCHA works on visa appointment systems.

Understand how BLS CAPTCHA works on visa appointment systems. Learn about its image selection mechanism, how i...

Automation BLS CAPTCHA
Apr 06, 2026
Troubleshooting BLS CAPTCHA Errors and Troubleshooting
BLS CAPTCHA solving has unique challenges because it uses a custom implementation.

BLS CAPTCHA solving has unique challenges because it uses a custom implementation. Here are the most common er...

Automation BLS CAPTCHA
Mar 05, 2026
Comparisons BLS CAPTCHA vs reCAPTCHA Grid — Comparison
Compare BLS CAPTCHA and re CAPTCHA grid challenges.

Compare BLS CAPTCHA and re CAPTCHA grid challenges. Learn the differences in format, solving approach, and Cap...

Automation Migration BLS CAPTCHA
Feb 12, 2026
Tutorials BLS CAPTCHA: Understanding Instructions Codes and Solving
how BLS CAPTCHA instruction codes work, how to extract grid images, and how to solve BLS CAPTCHAs with Captcha AI's API.

Learn how BLS CAPTCHA instruction codes work, how to extract grid images, and how to solve BLS CAPTCHAs with C...

Automation Python BLS CAPTCHA
Mar 15, 2026
API Tutorials Solve BLS CAPTCHA with Node.js and CaptchaAI
Step-by-step Node.js tutorial for solving BLS grid CAPTCHAs using the Captcha AI API.

Step-by-step Node.js tutorial for solving BLS grid CAPTCHAs using the Captcha AI API. Includes grid extraction...

Automation BLS CAPTCHA Node.js
Mar 07, 2026
API Tutorials Solve BLS CAPTCHA with Python and CaptchaAI
Step-by-step Python tutorial for solving BLS grid CAPTCHAs using the Captcha AI API.

Step-by-step Python tutorial for solving BLS grid CAPTCHAs using the Captcha AI API. Includes image extraction...

Automation Python BLS CAPTCHA
Mar 29, 2026
Reference CAPTCHA Token Injection Methods Reference
Complete reference for injecting solved CAPTCHA tokens into web pages.

Complete reference for injecting solved CAPTCHA tokens into web pages. Covers re CAPTCHA, Turnstile, and Cloud...

Automation Python reCAPTCHA v2
Apr 08, 2026
Troubleshooting GeeTest v3 Error Codes: Complete Troubleshooting Reference
Complete reference for Gee Test v 3 error codes — from registration failures to validation errors — with causes, fixes, and Captcha AI-specific troubleshooting.

Complete reference for Gee Test v 3 error codes — from registration failures to validation errors — with cause...

Automation Testing GeeTest v3
Apr 08, 2026
API Tutorials How to Solve reCAPTCHA v2 Callback Using API
how to solve re CAPTCHA v 2 callback implementations using Captcha AI API.

Learn how to solve re CAPTCHA v 2 callback implementations using Captcha AI API. Detect the callback function,...

Automation reCAPTCHA v2 Webhooks
Mar 01, 2026
API Tutorials Solve GeeTest v3 CAPTCHA with Python and CaptchaAI
Step-by-step Python tutorial for solving Gee Test v 3 slide puzzle CAPTCHAs using the Captcha AI API.

Step-by-step Python tutorial for solving Gee Test v 3 slide puzzle CAPTCHAs using the Captcha AI API. Includes...

Automation Python Testing
Mar 23, 2026
API Tutorials Case-Sensitive CAPTCHA API Parameter Guide
How to use the regsense parameter for case-sensitive CAPTCHA solving with Captcha AI.

How to use the regsense parameter for case-sensitive CAPTCHA solving with Captcha AI. Covers when to use, comm...

Python Web Scraping Image OCR
Apr 09, 2026