NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

AWS WAF and other CAPTCHAs

reCAPTCHA image grids with classification tasks

Sometimes you need to answer the reCAPTCHA picture grid itself rather than skip it with a token. A classification task tells you which tiles to click for $0.28 per 1,000.

Grid answers versus tokens

For almost every automation job, a token task is the simpler way through reCAPTCHA v2: send the site key and page URL, receive a g-recaptcha-response, put it in the form. You never see the pictures. The guide to solving reCAPTCHA v2 in Python shows that route.

The classification task answers a different question: "which of these tiles show a traffic light?" You use it when your script drives a real browser and must interact with the visible challenge, for example:

  • accessibility tooling that helps a person who cannot see the images complete the challenge in their own browser;
  • a QA test that must exercise the real widget end to end on your own staging site;
  • a recorded RPA flow where the visible browser session must complete the puzzle itself.

How the grid is built

After the checkbox, reCAPTCHA may open a challenge frame (its URL contains api2/bframe). At the time of writing it shows an instruction such as "Select all images with traffic lights" and one of two layouts:

LayoutWhat you captureIndex range
3 by 3, nine separate photosThe full grid as one image0 to 8
4 by 4, one photo cut into squaresThe full grid as one image0 to 15

Indexes run from the top left tile, left to right and then down, starting at 0. In the 3 by 3 layout tile 4 is the center; in the 4 by 4 layout the bottom right tile is 15. Some 3 by 3 rounds are dynamic: a clicked tile fades and a new photo appears in its place, and you keep going until no matching tiles remain.

The task fields

The type is ReCaptchaV2Classification with two required fields. image holds the base64 of the challenge image, and question names the object to find. The answer comes back as {"objects": [0, 3, 6]}, the indexes to click.

For question, send the object code in the form reCAPTCHA uses internally, such as /m/015qff for traffic lights. Map the instruction text to a code with a small table. The codes below are ones commonly seen in grid challenges; confirm against what you observe, since Google can add or change objects.

Instruction wordquestion value
traffic lights/m/015qff
cars/m/0k4j
buses/m/01bjv
bicycles/m/0199g
motorcycles/m/04_sv
fire hydrants/m/01pns0
crosswalks/m/014xcs

Capture the grid in Playwright

The challenge lives inside an iframe, so locate it with frame_locator and work inside it. The selectors here match the challenge markup at the time of writing; check them in DevTools before you rely on them.

import base64

OBJECT_CODES = {"traffic lights": "/m/015qff", "cars": "/m/0k4j",
                "buses": "/m/01bjv", "bicycles": "/m/0199g",
                "motorcycles": "/m/04_sv", "fire hydrants": "/m/01pns0",
                "crosswalks": "/m/014xcs"}

def grab_challenge(page):
    frame = page.frame_locator("iframe[src*='api2/bframe']")
    target = frame.locator(".rc-imageselect-desc-wrapper strong").first.inner_text()
    code = OBJECT_CODES.get(target.strip().lower())
    if code is None:
        raise KeyError(f"no object code for {target!r}")
    grid = frame.locator(".rc-imageselect-challenge")
    picture = base64.b64encode(grid.screenshot()).decode()
    cells = frame.locator("td.rc-imageselect-tile")
    return frame, code, picture, cells

Screenshotting the whole challenge area gives the solver the full grid as one picture, matching the layouts in the table above. Keep the count of cells: nine means indexes 0 to 8, sixteen means 0 to 15.

Classify and click

import time
import requests

GRID_API = "https://gatesolver.com"

def pick_tiles(picture: str, code: str, key: str) -> list[int]:
    made = requests.post(f"{GRID_API}/createTask", timeout=30, json={
        "clientKey": key,
        "task": {"type": "ReCaptchaV2Classification", "image": picture, "question": code},
    }).json()
    if made.get("errorId"):
        raise RuntimeError(f"createTask refused: {made['errorCode']}")
    for _ in range(90):
        time.sleep(1)
        out = requests.post(f"{GRID_API}/getTaskResult", timeout=30,
                            json={"taskId": made["taskId"], "clientKey": key}).json()
        if out.get("errorId") or out.get("status") == "failed":
            raise RuntimeError(out.get("errorCode", "classification failed"))
        if out.get("status") == "ready":
            return out["solution"]["objects"]
    raise RuntimeError("grid not classified in time")

def answer_round(page, key: str) -> None:
    frame, code, picture, cells = grab_challenge(page)
    for idx in pick_tiles(picture, code, key):
        cells.nth(idx).click()
        page.wait_for_timeout(300)
    frame.locator("#recaptcha-verify-button").click()

Image tasks are polled every second, since they finish much faster than token tasks. The pause between clicks gives the widget time to mark each tile and, in dynamic rounds, to start fading in a replacement.

Dynamic rounds and repeat challenges

When a round replaces clicked tiles, wait for the new photos to load, capture the grid again and classify again. Stop when the task returns an empty list, then press Verify. After Verify, reCAPTCHA may show another round, with the same or a different object. Write the loop around these checks:

  1. After clicking Verify, wait a second and check whether the challenge frame is still visible.
  2. If it is, run answer_round again. Cap the number of rounds at five or so to avoid loops on a broken page.
  3. If the checkbox frame now shows a tick, read the token from the page's g-recaptcha-response textarea or let the site's own form submit carry it.

Each classification is a separate task billed only when solved, so several rounds cost several tasks. That is one more reason token tasks are the default for bulk work and grid answers are kept for cases that need the visible interaction.

Accuracy tips

  • Capture after load. Wait for tile images to finish loading; a half loaded grid leads to wrong picks.
  • Do not resize. Send the screenshot at the size it was taken. Scaling down blurs small objects such as distant traffic lights.
  • Match the object exactly. "Bus" and "buses" map to the same code; normalise plurals in your table.
  • Unknown objects. If the instruction names something not in your table, click the reload icon in the challenge to get a different object instead of guessing.

Errors you may see

ERROR_INVALID_TASK_DATA means a field is missing or empty, usually the image because the grid locator matched nothing. ERROR_CAPTCHA_UNSOLVABLE appears on blank or corrupted captures and is free. ERROR_ZERO_BALANCE stops all tasks until you top up. The error handling guide shows a retry wrapper that treats each code correctly.

Picture grids are a real barrier for people with low vision. Assistive tools that answer the grid in the user's own browser are one of the most useful applications of this task type.

The reCAPTCHA image classification page lists the current price, and the image classification CAPTCHA glossary entry explains the general idea.

Common questions

Which index is the top left tile?

Index 0. Indexes run left to right and then top to bottom, so a 3 by 3 grid ends at 8 and a 4 by 4 grid ends at 15.

Should I send each tile as a separate image?

No. Send the whole grid as one image in the image field; the returned indexes refer to positions in that grid.

What value goes in the question field?

The object code for the instruction, for example /m/015qff for traffic lights. Keep a mapping table from instruction words to codes.

Is a classification task cheaper than a token task?

Per task it is priced on its own line on the pricing page. Several rounds can each need a task, so token tasks are usually simpler for bulk work.

What should I do with a dynamic 3 by 3 round?

Capture and classify again after new tiles appear, and press Verify once a task returns an empty list.

Keep reading