Explainers

GeeTest v4 CAPTCHA Changes and Solving Guide

GeeTest v4 brings significant changes in architecture, challenge types, and integration patterns compared to v3. This guide explains what changed and how to solve v4 challenges.


GeeTest v3 vs v4 — Key Differences

Feature GeeTest v3 GeeTest v4
Initialization gt + challenge from server captcha_id only
Challenge parameter Required from API call Generated client-side
Challenge types Slide, click Slide, click, icon select, space reasoning
Validation Server returns challenge Uses lot_number + pass_token
API endpoint api.geetest.com gcaptcha4.geetest.com
Difficulty scaling Fixed Adaptive risk scoring

Extracting GeeTest v4 Parameters

# extract_geetest_v4.py
import re
from selenium import webdriver


def extract_geetest_v4_params(url):
    """Extract GeeTest v4 captcha_id from a page."""
    driver = webdriver.Chrome()
    driver.get(url)

    page_source = driver.page_source

    # GeeTest v4 uses captcha_id instead of gt
    match = re.search(r'captcha_id["\']?\s*[:=]\s*["\']([a-f0-9]+)', page_source)
    captcha_id = match.group(1) if match else None

    # Check for v4-specific script
    is_v4 = "gcaptcha4" in page_source or "gt4.js" in page_source

    driver.quit()

    return {
        "captcha_id": captcha_id,
        "is_v4": is_v4,
        "pageurl": url,
    }


# Usage
params = extract_geetest_v4_params("https://example.com/login")
print(f"Captcha ID: {params['captcha_id']}")
print(f"Is v4: {params['is_v4']}")

Solving GeeTest v4 with CaptchaAI

# solve_geetest_v4.py
import requests
import time
import os


def solve_geetest_v4(captcha_id, pageurl):
    """Submit GeeTest v4 to CaptchaAI and get solution."""
    api_key = os.environ["CAPTCHAAI_API_KEY"]

    # Submit task
    resp = requests.post("https://ocr.captchaai.com/in.php", data={
        "key": api_key,
        "method": "geetest",
        "gt": captcha_id,      # captcha_id maps to the gt parameter
        "pageurl": pageurl,
        "version": "4",        # Specify v4 explicitly
        "json": 1,
    }, timeout=30)

    result = resp.json()
    if result.get("status") != 1:
        raise RuntimeError(f"Submit failed: {result.get('request')}")

    task_id = result["request"]

    # Poll for result
    time.sleep(10)
    for _ in range(30):
        resp = requests.get("https://ocr.captchaai.com/res.php", params={
            "key": api_key,
            "action": "get",
            "id": task_id,
            "json": 1,
        }, timeout=15)
        data = resp.json()

        if data.get("status") == 1:
            return data["request"]  # Contains validation tokens
        if data["request"] != "CAPCHA_NOT_READY":
            raise RuntimeError(data["request"])
        time.sleep(5)

    raise TimeoutError("GeeTest v4 solve timeout")


# Usage
solution = solve_geetest_v4(
    captcha_id="abc123def456",
    pageurl="https://example.com/login",
)
print(f"Solution: {solution}")

Injecting GeeTest v4 Solution

# inject_geetest_v4.py
import json
from selenium import webdriver
from selenium.webdriver.common.by import By


def inject_geetest_v4_solution(driver, solution):
    """Inject GeeTest v4 solution tokens into the page."""
    # Parse solution — v4 returns different tokens than v3
    if isinstance(solution, str):
        try:
            solution = json.loads(solution)
        except json.JSONDecodeError:
            pass

    # GeeTest v4 validation uses lot_number, pass_token, gen_time, captcha_output
    driver.execute_script("""
        var solution = arguments[0];

        // Set hidden form fields
        var fields = {
            'lot_number': solution.lot_number,
            'pass_token': solution.pass_token,
            'gen_time': solution.gen_time,
            'captcha_output': solution.captcha_output,
        };

        for (var name in fields) {
            var input = document.querySelector('input[name="' + name + '"]');
            if (!input) {
                input = document.createElement('input');
                input.type = 'hidden';
                input.name = name;
                document.forms[0].appendChild(input);
            }
            input.value = fields[name];
        }

        // Trigger validation callback if available
        if (window.captchaObj && typeof window.captchaObj.appendTo === 'function') {
            window.captchaObj.appendTo('#captcha-container');
        }
    """, solution)

v4 Challenge Types

Slide Puzzle

The classic slide-to-match challenge. User drags a puzzle piece.

Click Selection

User clicks specific objects (e.g., "click all faces"). Uses icon recognition.

Space Reasoning

New in v4 — user arranges shapes in a spatial pattern. More complex than v3.

Icon Match

User matches icons shown in a sequence. Harder to automate manually.

CaptchaAI handles all v4 challenge types — the API abstracts away the challenge-specific logic.


Troubleshooting

Issue Cause Fix
ERROR_WRONG_CAPTCHA_ID Using v3 gt value instead of v4 captcha_id Check the page for gcaptcha4 script to confirm v4
Solution rejected Missing version=4 parameter Always specify version: "4" for v4
captcha_id not found JavaScript-rendered Use Selenium to extract from rendered page
Token format error Parsing string instead of JSON Parse solution as JSON to get individual tokens

FAQ

How do I know if a site uses GeeTest v3 or v4?

Look for gcaptcha4.geetest.com or gt4.js in the page source for v4. If you see api.geetest.com and a challenge parameter, it's v3.

Is GeeTest v4 harder to solve than v3?

For automated solvers, no. CaptchaAI handles both versions. V4's adaptive difficulty affects end-user friction but not API-based solving.

What's the success rate for GeeTest v4?

CaptchaAI reports 100% success rate for GeeTest challenges, consistent across v3 and v4.



Solve GeeTest v4 challenges — start with CaptchaAI.

Discussions (0)

No comments yet.