GeeTestTask
这种类型的任务是通过您的代理解决 GeeTest 验证码的问题。
您的应用程序应发送站点地址、公共域键 (gt
)、键 (challenge
) 和代理。
解决问题的结果是用于提交表单的三个或五个令牌。
暂不支持带有 IP 授权的代理。
对象结构
gt
、challenge
和geetestApiServerSubdomain
参数通常可以在initGeetest
JavaScript 函数内找到。- 您还可以在页面的 HTML 代码中找到它们。您可以在页面完全加载后在
<sсript>
块中找到它们。
V3
V4 (captcha_id = gt)
GeeTest V3
可能的验证码变体。
- Intelligent mode
- Slide CAPTCHA
- Icon CAPTCHA
- Space CAPTCHA
请求参数
type
<string>requiredGeeTestTask
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 V43
geetestApiServerSubdomain
<string>optionalGeetest API 子域服务器(必须与 api.geetest.com 不同)。
可选参数。某些站点可能需要。
geetestGetLib
<string>optional展示验证码脚本的路径。
可选参数。某些站点可能需要。
以字符串形式发送 JSON。
proxyType
<string>optionalhttp - 常规的 HTTP/HTTPS 代理;
https - 仅当 "http" 不起作用时尝试此选项(某些自定义代理需要);
socks4 - socks4 代理;
socks5 - socks5 代理。
proxyAddress
<string>optionalIPv4/IPv6 代理 IP 地址。不允许使用:
- 使用主机名;
- 使用透明代理(可以看到客户端 IP);
- 使用本地机器上的代理。
proxyPort
<integer>optional代理端口。
proxyLogin
<string>optional代理服务器登录名。
proxyPassword
<string>optional代理服务器密码。
userAgent
<string>optional用于识别验证码的浏览器 User-Agent。
创建任务
- GeeTestTask (without proxy)
- GeeTestTask (using proxy)
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
}
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",
"proxyType":"http",
"proxyAddress":"8.8.8.8",
"proxyPort":8080,
"proxyLogin":"proxyLoginHere",
"proxyPassword":"proxyPasswordHere",
"userAgent":"userAgentPlaceholder"
}
}
回应
{
"errorId":0,
"taskId":407533072
}
使用 getTaskResult 方法获取 GeeTest 识别结果。根据系统负载,您将在 10 到 30 秒内收到响应。
Get task result
https://api.capmonster.cloud/getTaskResult
要求
{
"clientKey":"API_KEY",
"taskId": 407533072
}
回应
{
"errorId":0,
"status":"ready",
"solution": {
"challenge":"0f759dd1ea6c4wc76cedc2991039ca4f23",
"validate":"6275e26419211d1f526e674d97110e15",
"seccode":"510cd9735583edcb158601067195a5eb|jordan"
}
}
属性 | 类型 | 描述 |
---|---|---|
challenge | String | 在目标网站提交表单时,这三个参数 都是必需的。 |
validate | String | |
seccode | String |
使用 SDK 库
- JavaScript
- Python
- C#
// 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));
});
# https://github.com/ZennoLab/capmonstercloud-client-python
# GeeTestV3:
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import GeetestRequest
client_options = ClientOptions(api_key="your_api_key") # Replace with your CapMonsterCloud API key
cap_monster_client = CapMonsterClient(options=client_options)
geetest_request = GeetestRequest(
websiteUrl="https://example.com", # Website with the captcha
gt="your_gt_value", # Replace with the 'gt' parameter
challenge="your_challenge_value" # Replace with the 'challenge' parameter
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(geetest_request)
responses = asyncio.run(solve_captcha())
print(responses)
# Geetest V3
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import GeetestRequest
client_options = ClientOptions(api_key="your_api_key") # Replace with your CapMonsterCloud API key
cap_monster_client = CapMonsterClient(options=client_options)
geetest_request = GeetestRequest(
websiteUrl="https://example.com", # Website with the captcha
gt="your_gt_value",
challenge="your_challenge_value",
proxyType="http", # Type of proxy (http, https, socks4, socks5)
proxyAddress="8.8.8.8",
proxyPort=8080,
proxyLogin="proxyLoginHere",
proxyPassword="proxyPasswordHere",
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" # Use the current userAgent
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(geetest_request)
responses = asyncio.run(solve_captcha())
print(responses)
// https://github.com/ZennoLab/capmonstercloud-client-dotnet
// GeeTestV3:
using Zennolab.CapMonsterCloud.Requests;
using Zennolab.CapMonsterCloud;
class Program
{
static async Task Main(string[] args)
{
var clientOptions = new ClientOptions
{
ClientKey = "your_api_key" // Replace with your CapMonster Cloud API key
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
var geetestRequest = new GeeTestRequest
{
WebsiteUrl = "https://example.com/demo/geetest", // URL with the captcha
Gt = "your_gt_value", // Replace with the actual gt value
Challenge = "your_challenge_value" // Replace with the actual challenge value
};
var geetestResult = await cmCloudClient.SolveAsync(geetestRequest);
Console.WriteLine("Captcha Solution:");
Console.WriteLine($"Challenge: {geetestResult.Solution.Challenge}");
Console.WriteLine($"Validate: {geetestResult.Solution.Validate}");
Console.WriteLine($"SecCode: {geetestResult.Solution.SecCode}");
}
}
// Geetest V3
using Zennolab.CapMonsterCloud.Requests;
using Zennolab.CapMonsterCloud;
class Program
{
static async Task Main(string[] args)
{
var clientOptions = new ClientOptions
{
ClientKey = "your_api_key" // Replace with your CapMonster Cloud API key
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
var geetestRequest = new GeeTestRequest
{
WebsiteUrl = "https://example.com/demo/geetest", // URL with the captcha
Gt = "your_gt_value", // Replace with the actual gt value
Challenge = "your_challenge_value",
ProxyType = ProxyType.Http,
ProxyAddress = "8.8.8.8",
ProxyPort = 8080,
ProxyLogin = "proxyLoginHere",
ProxyPassword = "proxyPasswordHere"
};
var geetestResult = await cmCloudClient.SolveAsync(geetestRequest);
Console.WriteLine("Captcha Solution:");
Console.WriteLine($"Challenge: {geetestResult.Solution.Challenge}");
Console.WriteLine($"Validate: {geetestResult.Solution.Validate}");
Console.WriteLine($"SecCode: {geetestResult.Solution.SecCode}");
}
}
GeeTest V4
可能的验证码变体
请求参数
type
<string>requiredGeeTestTask
websiteURL
<string>required解决验证码的页面地址。
gt
<string>required该域名的 GeeTest 标识符键 - captcha_id
参数。
version
<integer>required only for V44
geetestApiServerSubdomain
<string>optionalGeetest API 子域名服务器(必须不同于 api.geetest.com)。
可选参数。某些网站可能需要此参数。
geetestGetLib
<string>optional用于在页面上显示验证码的脚本路径。
可选参数。某些网站可能需要此参数。
将 JSON 作为字符串发送。
initParameters
<object>optional版本 4 的附加参数,与“riskType”(验证码类型/验证特征)一起使用。
proxyType
<string>optionalhttp - 常规的 HTTP/HTTPS 代理;
https - 仅当 "http" 不起作用时尝试此选项(某些自定义代理需要);
socks4 - socks4 代理;
socks5 - socks5 代理。
proxyAddress
<string>optionalIPv4/IPv6 代理 IP 地址。不允许使用:
- 使用主机名;
- 使用透明代理(可以看到客户端 IP);
- 使用本地机器上的代理。
proxyPort
<integer>optional代理端口。
proxyLogin
<string>optional代理服务器登录名。
proxyPassword
<string>optional代理服务器密码。
userAgent
<string>optional用于识别验证码的浏览器 User-Agent。
Create task method
- GeeTestTask (without proxy)
- GeeTestTask (using proxy)
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
}
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"
},
"proxyType":"http",
"proxyAddress":"8.8.8.8",
"proxyPort":8080,
"proxyLogin":"proxyLoginHere",
"proxyPassword":"proxyPasswordHere",
"userAgent":"userAgentPlaceholder"
}
}
回应
{
"errorId":0,
"taskId":407533072
}
使用 getTaskResult 方法获取 GeeTest 识别结果。根据系统负载,您将在 10 到 30 秒内收到响应。
获取任务结果方法
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_id | String | 在目标网站提交表单时,这五个参数都是必需的。 input[name=captcha_id] input[name=lot_number] input[name=pass_token] input[name=gen_time] input[name=captcha_output] |
lot_number | String | |
pass_token | String | |
gen_time | String | |
captcha_output | String |
使用 SDK 库
- JavaScript
- Python
- C#
// 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));
});
# https://github.com/ZennoLab/capmonstercloud-client-python
# GeeTestV4
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import GeetestRequest
client_options = ClientOptions(api_key = "your_api_key") # Replace with your CapMonsterCloud API key
cap_monster_client = CapMonsterClient(options = client_options)
gee_test_request = GeetestRequest(
websiteUrl = "https://example.com/", # Website with the captcha
gt = "54088bb07d2df3c46b79f80300b0abbe",
version = 4,
initParameters = {
"riskType": "slide"
}
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(gee_test_request)
responses = asyncio.run(solve_captcha())
print(responses)
# GeeTestV4
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import GeetestRequest
client_options = ClientOptions(api_key = "your_api_key") # Replace with your CapMonsterCloud API key
cap_monster_client = CapMonsterClient(options = client_options)
gee_test_request = GeetestRequest(
websiteUrl = "https://example.com/", # Website with the captcha
gt = "54088bb07d2df3c46b79f80300b0abbe",
version = 4,
initParameters = {
"riskType": "slide"
},
proxyType = "http", # Type of proxy (http, https, socks4, socks5)
proxyAddress = "8.8.8.8",
proxyPort = 8080,
proxyLogin = "proxyLoginHere",
proxyPassword = "proxyPasswordHere",
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" # Use the current userAgent
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(gee_test_request)
responses = asyncio.run(solve_captcha())
print(responses)
// https://github.com/ZennoLab/capmonstercloud-client-dotnet
// GeeTestV4
using Zennolab.CapMonsterCloud.Requests;
using Zennolab.CapMonsterCloud;
class Program
{
static async Task Main(string[] args)
{
var clientOptions = new ClientOptions
{
ClientKey = "your_api_key" // Replace with your CapMonster Cloud API key
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
var geetestRequest = new GeeTestRequest
{
WebsiteUrl = "https://example.com/", // Website with the captcha
Gt = "54088bb07d2df3c46b79f80300b0abbe",
Version = 4,
InitParameters = new Dictionary<string, string> { { "riskType", "slide" } }
};
var geetestResult = await cmCloudClient.SolveAsync(geetestRequest);
Console.WriteLine("Captcha Solution:");
Console.WriteLine($"CaptchaId: {geetestResult.Solution.CaptchaId}");
Console.WriteLine($"LotNumber: {geetestResult.Solution.LotNumber}");
Console.WriteLine($"PassToken: {geetestResult.Solution.PassToken}");
Console.WriteLine($"GenTime: {geetestResult.Solution.GenTime}");
Console.WriteLine($"CaptchaOutput: {geetestResult.Solution.CaptchaOutput}");
}
}
// Geetest V4
using Zennolab.CapMonsterCloud.Requests;
using Zennolab.CapMonsterCloud;
class Program
{
static async Task Main(string[] args)
{
var clientOptions = new ClientOptions
{
ClientKey = "your_api_key" // Replace with your CapMonster Cloud API key
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
var geetestRequest = new GeeTestRequest
{
WebsiteUrl = "https://example.com/", // Website with the captcha
Gt = "54088bb07d2df3c46b79f80300b0abbe", // Replace with the correct gt value
Version = 4,
InitParameters = new Dictionary<string, string> { { "riskType", "slide" } },
ProxyType = ProxyType.Http,
ProxyAddress = "8.8.8.8",
ProxyPort = 8080,
ProxyLogin = "proxyLoginHere",
ProxyPassword = "proxyPasswordHere"
};
var geetestResult = await cmCloudClient.SolveAsync(geetestRequest);
Console.WriteLine("Captcha Solution:");
Console.WriteLine($"CaptchaId: {geetestResult.Solution.CaptchaId}");
Console.WriteLine($"LotNumber: {geetestResult.Solution.LotNumber}");
Console.WriteLine($"PassToken: {geetestResult.Solution.PassToken}");
Console.WriteLine($"GenTime: {geetestResult.Solution.GenTime}");
Console.WriteLine($"CaptchaOutput: {geetestResult.Solution.CaptchaOutput}");
}
}