More languages
How to solve GeeTest in Node.js
In a Playwright session, the easiest way to find GeeTest parameters is to listen to the requests the widget makes. This guide captures them, solves the puzzle through the API at $0.84 per 1,000, and completes the protected action from the same page.
The approach
GeeTest's script talks to its own servers before it shows a puzzle. For v4 it requests a load endpoint whose URL contains captcha_id; for v3 the page first calls the site's own register endpoint, which returns gt and challenge. Playwright can observe both with page.on('request') and page.on('response'), so you never have to dig through minified scripts. Once you have the parameters, the API returns the result fields, and the page's own verification request carries them to the site.
You need Node.js 18 or newer (for global fetch) and Playwright (npm i playwright, then npx playwright install chromium). The examples use ES modules.
A compact solver module
// geetest-api.mjs
const ROOT = 'https://gatesolver.com';
const KEY = process.env.GATESOLVER_KEY ?? 'YOUR_API_KEY';
const later = (ms) => new Promise((go) => setTimeout(go, ms));
async function api(route, extra) {
const r = await fetch(`${ROOT}/${route}`, {
method: 'POST',
headers: { 'content-type': 'application/json' }, // JSON in, JSON out
body: JSON.stringify({ clientKey: KEY, ...extra }),
signal: AbortSignal.timeout(20_000),
});
const data = await r.json();
if (data.errorId) throw Object.assign(new Error(data.errorCode), { code: data.errorCode });
return data;
}
export async function solveGeeTest({ pageUrl, captchaId, gt, challenge }) {
const task = { type: 'GeeTestTaskProxyLess', websiteURL: pageUrl };
if (captchaId) task.captchaId = captchaId;
else Object.assign(task, { gt, challenge });
const { taskId } = await api('createTask', { task });
for (const stopAt = Date.now() + 125_000; Date.now() < stopAt; ) {
await later(3000);
const poll = await api('getTaskResult', { taskId });
if (poll.status === 'ready') return poll.solution;
if (poll.status === 'failed') throw new Error('GeeTest task failed (free)');
}
throw new Error('GeeTest result not ready in time');
}
Attaching the error code to the thrown error as code lets callers branch on it, for example to stop on ERROR_ZERO_BALANCE and retry once on ERROR_CAPTCHA_UNSOLVABLE.
Capture the parameters from the page
Start listening before navigation, so the first request is not missed. The listener resolves a promise as soon as the parameters appear.
// capture.mjs
export function watchGeeTest(page, registerPath = '/captcha/register') {
return new Promise((resolve) => {
page.on('request', (outgoing) => {
const u = new URL(outgoing.url());
if (u.hostname.includes('geetest.com') && u.searchParams.has('captcha_id')) {
resolve({ version: 4, captchaId: u.searchParams.get('captcha_id') });
}
});
page.on('response', async (incoming) => {
if (!incoming.url().includes(registerPath)) return;
try {
const body = await incoming.json();
if (body.gt && body.challenge) resolve({ version: 3, gt: body.gt, challenge: body.challenge });
} catch { /* not JSON, ignore */ }
});
});
}
Adjust registerPath to the site's own v3 endpoint, which you can spot once in the Network tab. For v4 no site specific path is needed, because the load request goes to GeeTest's domain with captcha_id in the query string. The exact host names can change; checking for geetest.com plus the parameter keeps the match loose.
Solve and complete the action
Here the protected action is a sign in form whose page posts the GeeTest v4 fields together with the credentials to /api/auth. Rather than trying to drive the puzzle UI, the script sends that request itself with page.request, which shares the browser context's cookies.
// main.mjs
import { chromium as chromeEngine } from 'playwright';
import { solveGeeTest } from './geetest-api.mjs';
import { watchGeeTest } from './capture.mjs';
const gtBrowser = await chromeEngine.launch();
const gtContext = await gtBrowser.newContext();
const page = await gtContext.newPage();
const params = watchGeeTest(page);
await page.goto('https://portal.example.io/signin');
await page.getByRole('button', { name: 'Sign in' }).click(); // many sites load GeeTest on this click
const found = await Promise.race([params, page.waitForTimeout(15_000).then(() => null)]);
if (!found) throw new Error('no GeeTest parameters seen');
const sol = await solveGeeTest({ pageUrl: page.url(), ...found });
const proof = found.version === 4
? { captcha_id: sol.captcha_id, lot_number: sol.lot_number, pass_token: sol.pass_token,
gen_time: sol.gen_time, captcha_output: sol.captcha_output }
: { geetest_challenge: sol.challenge, geetest_validate: sol.validate, geetest_seccode: sol.seccode };
const reply = await page.request.post('https://portal.example.io/api/auth', {
data: { email: 'qa@example.io', password: process.env.PORTAL_TEST_PASS, ...proof },
});
console.log('auth reply', reply.status(), (await reply.text()).slice(0, 200));
await gtBrowser.close();
Field names and the endpoint come from your target; copy them from the request the browser sends after a manual solve. Some sites wrap the GeeTest fields in an object or send them as form data rather than JSON.
Why use the page's request context
page.request sends from the same browser context, so cookies set during navigation (session, CSRF, load balancer) go along automatically. The result is a request that looks like the one the page itself would make. If the site needs a CSRF header, read it from a meta tag with page.locator('meta[name=csrf-token]').getAttribute('content') and add it to headers.
v3 specifics
A v3 challenge is single use. If the script waits too long after capturing it, or a retry reuses it, the site rejects the result. On a retry, trigger the puzzle again (click the button or reload) so the page fetches a fresh challenge, and capture it anew.
Troubleshooting
- The promise never resolves. The widget loads lazily; click the control that opens it, or widen the request match.
- ERROR_INVALID_TASK_DATA. A v3 task is missing
gtorchallenge, or a v4 task is missingcaptchaId. - Site rejects valid results. A field was renamed, or more than a minute or two passed between solve and post.
Solves usually take under 5 seconds. The GeeTest v3 / v4 page lists the fields, and the Python GeeTest guide shows the same flow without a browser.
When the site reads the result from the widget
Some pages do not post the GeeTest fields themselves. Instead, the page's script calls captchaObj.getValidate() after the puzzle reports success and builds the request from what it returns. Sending the verification request yourself, as above, sidesteps that and is usually the simplest route. If the site's request is complex (signed parameters, extra fields computed in the page), an alternative is to intercept it with page.route: let the page build and send its request, and in the route handler replace the GeeTest fields in the body with the values from the API before calling route.continue({ postData }). Use this only when copying the request by hand is impractical, since it depends on the page reaching the submit step.
Running headless in CI
The flow works headless, because the solve happens through the API and the page only needs to load the widget's scripts so the parameters appear. Store the API key and test credentials as CI secrets. For your own staging environment, ask whether GeeTest can be configured in a test mode for most suites, and keep real solves for a few end to end checks.
Concurrency
Each browser context captures its own parameters, so several contexts can solve in parallel. Keep total API calls under 600 per minute per key.
Capturing in a fresh context each time
The listeners are attached to one page and resolve once. For a second solve on the same page, call watchGeeTest again before triggering the puzzle, so the new promise catches the new parameters. When running many pages in a loop, create a new page or context per item and close it afterwards; this keeps the listeners, cookies and captured values from leaking between items and keeps memory use flat over long runs.
Common questions
Why listen to network requests instead of reading the page?
GeeTest parameters often live in minified scripts or arrive in responses. The network events show them directly.
Do I have to solve the puzzle inside the browser?
No. The API returns the result fields, and you send them in the verification request the page would make.
What is page.request in Playwright?
An API request context tied to the browser context, so requests share its cookies.
Can I reuse a captured v3 challenge on retry?
No. Trigger the puzzle again so the site issues a new challenge, and capture that one.
What Node.js release does the example assume?
Node.js 18 or newer for global fetch and AbortSignal.timeout.
Keep reading
- GeeTest v3 / v4 solver$0.84 per 1,000 tasks, answers under 5 seconds.
- PlaywrightPlaywright in Node.js and Python: read widget keys from the DOM or network, inject tokens, and add answers through route interception.
- Solve GeeTest in PythonAn async Python flow for GeeTest v3 and v4 using httpx and dataclasses, with the site verification request built from the result.
- GeeTestGeeTest v3 and v4 slide and click puzzles, the gt, challenge and captcha_id inputs, and the values a solve hands back.