跳转到主要内容
获取令牌时遇到问题吗
联系支持

GeeTestTask

这种类型的任务是通过您的代理解决 GeeTest 验证码的问题。 您的应用程序应发送站点地址、公共域键 (gt)、键 (challenge) 和代理。

解决问题的结果是用于提交表单的三个或五个令牌。

注意!

暂不支持带有 IP 授权的代理。

对象结构

信息
  • gtchallengegeetestApiServerSubdomain 参数通常可以在 initGeetest JavaScript 函数内找到。
  • 您还可以在页面的 HTML 代码中找到它们。您可以在页面完全加载后在 <sсript> 块中找到它们。

V3

V4 (captcha_id = gt)


GeeTest V3

可能的验证码变体。

请求参数

type<string>required

GeeTestTask


websiteURL<string>required

解决验证码的页面地址。正確的 Url 始終會傳給請求 https://api-na.geetest.com/gettype.php 上的 Referer?舉例來說: 我們在 https://example.com#login,但我們看到驗證碼實際上沒有在那裡初始化,而是在 https://example.com。


gt<string>required

该域名的 GeeTest 标识符键 gt。静态值,更新频率较低。


challenge<string>required only for V3

一个动态密钥。
每次调用我们的 API 时,我们需要获取一个新的密钥值。如果验证码已经加载在页面上,则 challenge 值不再有效,您将收到 错误 ERROR_TOKEN_EXPIRED
对于带有 ERROR_TOKEN_EXPIRED 错误的任务,将会收取费用。 需要检查请求并找到返回此值的请求,并在每次创建识别任务之前执行该请求并解析出挑战值。


version<integer>required only for V4

3


geetestApiServerSubdomain<string>optional

Geetest API 子域服务器(必须与 api.geetest.com 不同)。
可选参数。某些站点可能需要。


geetestGetLib<string>optional

展示验证码脚本的路径。
可选参数。某些站点可能需要。
以字符串形式发送 JSON。


proxyType<string>optional

http - 常规的 HTTP/HTTPS 代理;
https - 仅当 "http" 不起作用时尝试此选项(某些自定义代理需要);
socks4 - socks4 代理;
socks5 - socks5 代理。


proxyAddress<string>optional

IPv4/IPv6 代理 IP 地址。不允许使用:

- 使用主机名;

- 使用透明代理(可以看到客户端 IP);

- 使用本地机器上的代理。


proxyPort<integer>optional

代理端口。


proxyLogin<string>optional

代理服务器登录名。


proxyPassword<string>optional

代理服务器密码。


userAgent<string>optional

用于识别验证码的浏览器 User-Agent。

创建任务

POST
https://api.capmonster.cloud/createTask

要求

{
"clientKey":"YOUR_CAPMONSTER_CLOUD_API_KEY",
"task":
{
"type":"GeeTestTask",
"websiteURL":"https://www.geetest.com/en/demo",
"gt":"022397c99c9f646f6477822485f30404",
"challenge":"7f044f48bc951ecfbfc03842b5e1fe59",
"geetestApiServerSubdomain":"api-na.geetest.com"

}
}

回应

{
"errorId":0,
"taskId":407533072
}

使用 getTaskResult 方法获取 GeeTest 识别结果。根据系统负载,您将在 10 到 30 秒内收到响应。

Get task result

POST
https://api.capmonster.cloud/getTaskResult

要求

{
"clientKey":"API_KEY",
"taskId": 407533072
}

回应

{
"errorId":0,
"status":"ready",
"solution": {
"challenge":"0f759dd1ea6c4wc76cedc2991039ca4f23",
"validate":"6275e26419211d1f526e674d97110e15",
"seccode":"510cd9735583edcb158601067195a5eb|jordan"
}
}

属性类型描述
challengeString在目标网站提交表单时,这三个参数都是必需的。
validateString
seccodeString

使用 SDK 库

// https://github.com/ZennoLab/capmonstercloud-client-js

import { CapMonsterCloudClientFactory, ClientOptions, GeeTestRequest, /*GeeTestRequest*/ } from '@zennolab_com/capmonstercloud-client';

document.addEventListener('DOMContentLoaded', async () => {
const cmcClient = CapMonsterCloudClientFactory.Create(new ClientOptions({ clientKey: '<your capmonster.cloud API key>' }));
console.log(await cmcClient.getBalance());

const geetestV3Request = new GeeTestRequest({
websiteURL: 'https://example.com/geetest.php',
gt: '81dc9bdb52d04dc20036dbd8313ed055',
challenge: 'd93591bdf7860e1e4ee2fca799911215',
});

// const geetestV3Request = new GeeTestRequest({
// websiteURL: 'https://example.com/geetest.php',
// gt: '81dc9bdb52d04dc20036dbd8313ed055',
// challenge: 'd93591bdf7860e1e4ee2fca799911215',
// userAgent: 'userAgentPlaceholder',
// proxyType: 'https',
// proxyAddress: 'https://proxy.com',
// proxyPort: 6045,
// proxyLogin: 'login',
// proxyPassword: 'password',
// });

console.log(await cmcClient.Solve(geetestV3Request));
});

GeeTest V4

可能的验证码变体

请求参数

type<string>required

GeeTestTask


websiteURL<string>required

解决验证码的页面地址。


gt<string>required

该域名的 GeeTest 标识符键 - captcha_id 参数。


version<integer>required only for V4

4


geetestApiServerSubdomain<string>optional

Geetest API 子域名服务器(必须不同于 api.geetest.com)。
可选参数。某些网站可能需要此参数。


geetestGetLib<string>optional

用于在页面上显示验证码的脚本路径。
可选参数。某些网站可能需要此参数。
将 JSON 作为字符串发送。


initParameters<object>optional

版本 4 的附加参数,与“riskType”(验证码类型/验证特征)一起使用。


proxyType<string>optional

http - 常规的 HTTP/HTTPS 代理;
https - 仅当 "http" 不起作用时尝试此选项(某些自定义代理需要);
socks4 - socks4 代理;
socks5 - socks5 代理。


proxyAddress<string>optional

IPv4/IPv6 代理 IP 地址。不允许使用:

- 使用主机名;

- 使用透明代理(可以看到客户端 IP);

- 使用本地机器上的代理。


proxyPort<integer>optional

代理端口。


proxyLogin<string>optional

代理服务器登录名。


proxyPassword<string>optional

代理服务器密码。


userAgent<string>optional

用于识别验证码的浏览器 User-Agent。

Create task method

POST
https://api.capmonster.cloud/createTask

要求

{
"clientKey":"YOUR_CAPMONSTER_CLOUD_API_KEY",
"task":
{
"type":"GeeTestTask",
"websiteURL":"https://gt4.geetest.com/",
"gt":"54088bb07d2df3c46b79f80300b0abbe",
"version": 4,
"initParameters": {
"riskType": "slide"

}
}
}

回应

{
"errorId":0,
"taskId":407533072
}

使用 getTaskResult 方法获取 GeeTest 识别结果。根据系统负载,您将在 10 到 30 秒内收到响应。

获取任务结果方法

POST
https://api.capmonster.cloud/getTaskResult

要求

{
"clientKey":"API_KEY",
"taskId": 407533072
}

回应

{
"errorId":0,
"status":"ready",
"solution": {
"captcha_id":"f5c2ad5a8a3cf37192d8b9c039950f79",
"lot_number":"bcb2c6ce2f8e4e9da74f2c1fa63bd713",
"pass_token":"edc7a17716535a5ae624ef4707cb6e7e478dc557608b068d202682c8297695cf",
"gen_time":"1683794919",
"captcha_output":"XwmTZEJCJEnRIJBlvtEAZ662T...[cut]...SQ3fX-MyoYOVDMDXWSRQig56"
}
}

属性类型描述
captcha_idString在目标网站提交表单时,这五个参数都是必需的。
input[name=captcha_id]
input[name=lot_number]
input[name=pass_token]
input[name=gen_time]
input[name=captcha_output]
lot_numberString
pass_tokenString
gen_timeString
captcha_outputString

使用 SDK 库

// https://github.com/ZennoLab/capmonstercloud-client-js

import { CapMonsterCloudClientFactory, ClientOptions, GeeTestRequest, /*GeeTestRequest*/ } from '@zennolab_com/capmonstercloud-client';

document.addEventListener('DOMContentLoaded', async () => {
const cmcClient = CapMonsterCloudClientFactory.Create(new ClientOptions({ clientKey: '<your capmonster.cloud API key>' }));
console.log(await cmcClient.getBalance());

const geetestV4Request = new GeeTestRequest({
websiteURL: 'https://example.com/geetest.php',
gt: '81dc9bdb52d04dc20036dbd8313ed055',
challenge: 'd93591bdf7860e1e4ee2fca799911215',
version: '4',
initParameters: {
riskType: 'slide',
},
});

// const geetestV4Request = new GeeTestRequest({
// websiteURL: 'https://example.com/geetest.php',
// gt: '81dc9bdb52d04dc20036dbd8313ed055',
// challenge: 'd93591bdf7860e1e4ee2fca799911215',
// version: '4',
// initParameters: {
// riskType: 'slide',
// },
// userAgent: 'userAgentPlaceholder',
// proxyType: 'https',
// proxyAddress: 'https://proxy.com',
// proxyPort: 6045,
// proxyLogin: 'login',
// proxyPassword: 'p@ssword',
// })

console.log(await cmcClient.Solve(geetestV4Request));
});