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

Yidun - NECaptcha

任务示例

注意!

CapMonster Cloud 默认通过内置代理工作——这些代理已包含在费用内。仅当网站不接受令牌或对内置服务的访问受限时,才需要指定您自己的代理。

如果代理按 IP 授权,请将地址 65.21.190.34 加入白名单。

请求参数

type<string>required

YidunTask


websiteURL<string>required

验证码页面的完整网址。


websiteKey<string>required

页面中找到的 siteKey 参数的值(查看下方示例了解如何获取)。


userAgent<string>optional

浏览器的 User-Agent。
请仅传递最新的 Windows 系统 UA,目前推荐使用userAgentPlaceholder


yidunGetLib<string>optional

加载验证码的 JavaScript 文件路径。
重要:请提供完整链接(以 https:// 开头)。
推荐在页面中存在 challengehcghct 字段时使用。


yidunApiServerSubdomain<string>optional

Yidun API 服务器的子域名。
重要:必须不同于默认的 c.dun.163.comc-v6.dun.163.com
可包含 https://,也可以省略。
当使用自定义服务器(常见于企业版本)时是必填项。


challenge<string>optional

当前验证码的唯一标识符。
通常在验证码初始化或展示时通过网络请求传输。
是 Enterprise 验证码的标志。


hcg<string>optional

验证码的哈希值,用于构建请求。
通常与 challenge 一起提供。


hct<integer>optional

时间戳,用于验证 Enterprise 版本的验证码。


proxyType<string>optional

http - 普通 http/https 代理;
https - 如果 http 不工作,可以尝试此选项(部分自定义代理要求);
socks4 - socks4 代理;
socks5 - socks5 代理。


proxyAddress<string>optional

代理的 IPv4 或 IPv6 地址。禁止以下情况:

  • 使用透明代理(即暴露真实客户端 IP);
  • 使用本地代理地址。


proxyPort<integer>optional

代理端口。


proxyLogin<string>optional

代理用户名。


proxyPassword<string>optional

代理密码。


创建任务的方法

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

请求

{
"clientKey": "API_KEY",
"task":
{
"type": "YidunTask",
"websiteURL": "https://www.example.com",
"websiteKey": "6cw0f0485d5d46auacf9b735d20218a5",
"userAgent": "userAgentPlaceholder"
}
}

响应

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

获取结果的方法

使用方法 getTaskResult 获取 Yidun 验证码的解决结果。

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

请求

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

响应

{
"errorId": 0,
"errorCode": null,
"errorDescription": null,
"solution": {
"token": "CN31_9AwsPmaYcJameP_09rA0vkVMQsPij...RXTlFJFc3"
},
"status": "ready"
}

何时需要传递 yidunGetLibyidunApiServerSubdomain

如果您在开发者工具的 Network 标签中发现 challengehcghct 字段,则说明该网站使用的是 Enterprise(或 Business)版本的 Yidun,此时需额外传递 yidunGetLibyidunApiServerSubdomain 参数,以便正确解决。

任务示例
{
"type": "YidunTask",
"websiteURL": "https://id7.cloud.example.com/IframeLogin.html",
"websiteKey": "0f123r2a6am56431yg17n8rz6grz0ym6",
"userAgent": "userAgentPlaceholder",
"yidunGetLib": "https://example.com/captcha/b/v3//static/load.min.js",
"yidunApiServerSubdomain": "csc-captcha-example.com",
"challenge": "abc55382321547556267884cc3ba57c3d8a7c14f541fd9c6a7f1ce3173d3b9a1",
"hcg": "9a217825f3dcfac3d34e551e93819d610dec931e5e2a2236edf0e1f3f320c191",
"hct": 1751469954806
}

如何查找 websiteURLwebsiteKey

打开开发者工具,启动验证码,在 Network 标签中查找以 get?referer=check?referer= 开头的请求。参数 referer 的值就是 websiteURL

有时 referer 是 URL 编码的,例如:https%3A%2F%2Fid.example.com%2F。可在浏览器控制台中解码查看:

id 值即为 websiteKey


Yidun Enterprise 情况下:

websiteURLwebsiteKeyyidunApiServerSubdomain 可通过查找以 get?referer=check?referer= 开头的请求获得。


yidunGetLib

负责加载验证码的 JavaScript 文件路径,通常可在网络请求中找到,文件名类似于 load.min.js


challengehcghct

这些参数都可在网络请求中找到。相关请求通常以 cscPreprocess?reflushCode= 开头。

使用 SDK 库

显示代码(用于浏览器)
// https://github.com/ZennoLab/capmonstercloud-client-js

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

const API_KEY = "YOUR_API_KEY"; // 输入您的 CapMonster Cloud API 密钥

document.addEventListener("DOMContentLoaded", async () => {
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);

// 基本示例,无需代理
// CapMonster Cloud 会自动使用它们的代理
let yidunRequest = new YidunRequest({
websiteURL: "https://www.example.com", // 含有验证码的页面 URL
websiteKey: "6cw0f0485d5d46auacf9b735d20218a5",
userAgent: "userAgentPlaceholder"
});

// 使用您自己的代理的示例
// 如果想使用自己的代理,请取消注释以下代码块
/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password"
};

yidunRequest = new YidunRequest({
websiteURL: "https://www.example.com",
websiteKey: "6cw0f0485d5d46auacf9b735d20218a5",
userAgent: "userAgentPlaceholder",
proxy
});
*/

// 如有必要,可以检查余额
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(yidunRequest);
console.log("Solution:", result);
});
显示代码 (Node.js)
// https://github.com/ZennoLab/capmonstercloud-client-js

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

const API_KEY = "YOUR_API_KEY"; // 输入您的 CapMonster Cloud API 密钥

async function solveYidun() {
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);

// 基本示例,无需代理
// CapMonster Cloud 会自动使用它们的代理
let yidunRequest = new YidunRequest({
websiteURL: "https://www.example.com", // 含有验证码的页面 URL
websiteKey: "6cw0f0485d5d46auacf9b735d20218a5",
userAgent: "userAgentPlaceholder"
});

// 使用您自己的代理的示例
// 如果想使用自己的代理,请取消注释以下代码块

/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password"
};

yidunRequest = new YidunRequest({
websiteURL: "https://www.example.com", // 含有验证码的页面 URL
websiteKey: "6cw0f0485d5d46auacf9b735d20218a5",
userAgent: "userAgentPlaceholder",
proxy
});
*/

// 如有必要,可以检查余额
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(yidunRequest);
console.log("Solution:", result);
}

solveYidun().catch(err => console.error("错误:", err));