Captcha bypass tutorials

Was this helpful?

How to bypass and solve GeeTest v4 captcha automatically

Introduction

This guide is for developers who work with websites protected by GeeTest version 4 captcha and need to automate solving it. We will cover the technical details of GeeTest V4, show you how to extract the required parameters, and walk through practical examples of integrating with 2Captcha.

What you will need:

  • Python 3.8 or newer
  • Libraries: twocaptcha, asyncio
  • API key from 2Captcha
  • A working proxy (recommended for reliability)

1. Getting to know GeeTest V4 captcha

1.1. How the technology works

GeeTest V4 is a modern protection system against automated access. It uses improved behavioral analysis algorithms and interactive challenges. Compared to version 3, V4 makes integration simpler. You do not need to extract the dynamic challenge parameter. This reduces request preparation complexity and improves solving reliability.

1.2. Key GeeTest V4 parameters

Parameter Description Status
captcha_id Captcha identifier, a static value for the website Required
websiteURL Full URL of the page where the captcha loads Required
proxy Proxy server details Optional, but recommended

1.3. Task types in 2Captcha API

To solve GeeTest V4 captchas, the service supports two task types:

  1. GeeTestTaskProxyless — uses 2Captcha internal proxies, no proxy setup needed on your end
  2. GeeTestTask — requires you to specify your own proxy in the task parameters

1.4. Differences between GeeTest V3 and V4

Parameter GeeTest V3 GeeTest V4
Identifier gt (static) captcha_id (static)
Dynamic parameter challenge (must be extracted) Not required
API method solver.geetest() solver.geetest_v4()
Returned data geetest_challenge, geetest_validate, geetest_seccode lot_number, pass_token, gen_time, captcha_output
Integration complexity Medium Low

2. Setting up your environment

2.1. Installing dependencies

Install the required packages via pip:

bash Copy
pip3 install twocaptcha requests

2.2. Getting your API key

  1. Register on 2captcha.com
  2. Go to your account settings
  3. Copy your API key

For security, store the key in an environment variable:

bash Copy
# Linux/macOS
export APIKEY_2CAPTCHA=your_key_here

# Windows
set APIKEY_2CAPTCHA=your_key_here

3. Analyzing the page and extracting parameters

3.1. Identifying the captcha

GeeTest V4 appears as an interactive widget, often with a slider or image selection. The GeeTest logo is usually at the bottom of the widget.

3.2. Finding captcha_id in the source code

To extract captcha_id:

  1. Open DevTools in your browser (press F12)
  2. Go to the Elements tab
  3. Look for an element with the data-geetest attribute or the initGeetest4 call

Example HTML:

html Copy
<div id="geetest-captcha" data-geetest="e392e1d7fd421dc63325744d5a2b9c73"></div>

The value of the data-geetest attribute is your captcha_id.

3.3. Analyzing network requests

  1. In DevTools, switch to the Network tab
  2. Refresh the page with the captcha
  3. Filter requests by geetest or captcha

Key requests to watch:

  • GET https://gcaptcha4.geetest.com/load — loads captcha parameters
  • POST request with the solution to the target website

3.4. Server response structure

After solving the captcha, the service returns four parameters:

json Copy
{
  "lot_number": "e6c3bed2854f41f880662c48afff5dcb",
  "pass_token": "fad5eb52fc83bf7617402fcccfb211a21e0aa1d1044",
  "gen_time": "1693924478",
  "captcha_output": "fN36ufW6cQN4SQ-JRDQC70nSq9UcQBg=="
}

You must send these values to the target website for verification.


4. Building the solution in Python

4.1. Complete code example with asyncio

python Copy
import asyncio
import os
import sys

from twocaptcha import AsyncTwoCaptcha

# API key from environment variable or directly
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')

# Solver configuration
config = {
    'server': 'api.2captcha.com',  # Or 'rucaptcha.com'
    'apiKey': api_key,
    'softId': 123,  # Your app ID (optional)
    'defaultTimeout': 120,    # 2 minute timeout
    'recaptchaTimeout': 600,  # Timeout for reCAPTCHA (not used for GeeTest)
    'pollingInterval': 10,    # How often to poll for results
}

solver = AsyncTwoCaptcha(**config)

async def solve_captcha():
    try:
        # Send GeeTest V4 task for solving
        return await solver.geetest_v4(
            captcha_id='e392e1d7fd421dc63325744d5a2b9c73',  # Static captcha ID
            url='https://example.com/demo/geetest-v4',        # Page URL with captcha
            # Proxy (uncomment if needed):
            # proxy={
            #     'type': 'HTTPS',
            #     'uri': 'login:password@IP_address:PORT'
            # }
        )
    except Exception as e:
        print(f"Error solving captcha: {e}")
        sys.exit(1)

if __name__ == '__main__':
    result = asyncio.run(solve_captcha())
    print('Solution received:', result)

4.2. Code breakdown

Solver configuration:

  • server — which server to send requests to (2captcha.com or rucaptcha.com)
  • defaultTimeout=120 — maximum wait time for a solution
  • pollingInterval=10 — how often to check task status
  • softId — your application identifier (optional, for stats)

The geetest_v4() method:

  • Takes captcha_id and url as required parameters
  • Does not need a dynamic challenge, unlike V3
  • Returns a dictionary with: lot_number, pass_token, gen_time, captcha_output

Error handling:

  • The try/except block catches network and API errors
  • On failure, the script prints an error message and exits with code 1

V4 advantages:

  • Simpler integration without dynamic parameters
  • Fewer steps to prepare the request
  • More consistent behavior across different websites

5. Alternative methods and extra settings

5.1. Synchronous library version

If you are not using asyncio, you can use the synchronous client:

python Copy
from twocaptcha import TwoCaptcha

solver = TwoCaptcha(api_key)

result = solver.geetest_v4(
    captcha_id='e392e1d7fd421dc63325744d5a2b9c73',
    url='https://example.com/demo/geetest-v4'
)

5.2. Setting up a proxy

Using a proxy improves resistance to blocks:

python Copy
proxy_config = {
    'type': 'HTTPS',
    'uri': 'login:password@1.2.3.4:8080'
}

result = await solver.geetest_v4(
    captcha_id='e392e1d7fd421dc63325744d5a2b9c73',
    url='https://example.com/demo/geetest-v4',
    proxy=proxy_config
)

Proxy tips:

  • Use residential proxies from the relevant region
  • Rotate proxies for multiple requests
  • Test proxy connectivity before running your script

5.3. Error handling and retries

python Copy
import time

max_retries = 3
for attempt in range(max_retries):
    try:
        result = await solver.geetest_v4(...)
        break
    except Exception as e:
        print(f"Attempt {attempt + 1} failed: {e}")
        time.sleep(5)
else:
    print("All attempts exhausted")

5.4. Using the solution

Once you have the captcha solution, send it to the target website. Usually the site sends solved data in a request you can intercept with developer tools.

Find the request that contains the solved captcha data and replay it with your obtained parameters:

  • lot_number
  • pass_token
  • gen_time
  • captcha_output

Example of sending the solution to the target website:

python Copy
import requests

# Parameters received from 2Captcha
solution = result['code']  # or result['solution'] depending on format

# Request headers (adjust for your target site)
headers = {
    'Content-Type': 'application/json',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
}

# Data to send
payload = {
    'lot_number': solution['lot_number'],
    'pass_token': solution['pass_token'],
    'gen_time': solution['gen_time'],
    'captcha_output': solution['captcha_output']
}

# Send the solution
response = requests.post(
    'https://example.com/verify-captcha',
    headers=headers,
    json=payload
)

if response.status_code == 200:
    print("Captcha verified successfully")

6. Common errors and fixes

Error Possible cause Solution
ERROR_WRONG_USER_KEY Invalid API key Check your key in account settings
ERROR_ZERO_BALANCE Insufficient funds Top up your balance on 2captcha.com
ERROR_CAPTCHA_UNSOLVABLE Captcha not recognized Verify captcha_id and url are correct
ERROR_PROXY_CONNECT_REFUSED Proxy unreachable Check proxy details and connectivity
invalid captcha_id Wrong captcha identifier Extract the current captcha_id from source code
timeout Wait time exceeded Increase defaultTimeout or check service status
ERROR_BAD_PARAMETERS Invalid task parameters Verify captcha_id and websiteURL format

6.1. Debugging requests

To troubleshoot issues, add logging for intermediate data:

python Copy
print(f"captcha_id: {captcha_id_value}")
print(f"url: {target_url}")
print(f"Response from api.2captcha.com: {result}")

7. Additional resources

Code examples in other languages:


8. Pre-launch checklist

  • Installed twocaptcha and requests packages
  • API key is correct and has a positive balance
  • captcha_id extracted from the target website source code
  • Correct websiteURL provided, full link to the captcha page
  • If using a proxy, details and connectivity verified
  • Reasonable timeouts set (defaultTimeout, pollingInterval)
  • Script tested in debug mode before production use
  • Error handling and retry logic implemented
  • Solution submission format to target website verified

Wrapping up

GeeTest V4 simplifies integration because you do not need to extract the dynamic challenge parameter. The Python solution shown here, built with the twocaptcha library, provides reliable captcha solving with minimal effort.

Key recommendations:

  • Always verify captcha_id is up to date before sending a task
  • Use proxies to improve solving success rates
  • Set timeouts that match your workload
  • Implement retry logic to handle temporary failures
  • Send all four solution parameters correctly to the target website

Integrating with 2Captcha lets you focus on your application logic while delegating captcha solving to a specialized service. Follow the setup, parameter extraction, and error handling guidance in this guide, and you will be able to reliably automate interactions with protected websites.