2captcha-wrapper 中文文档教程
NODE.js 2captcha wrapper
这是一个 node.js 模块,用于使用 2captcha 服务解决 google 的 recaptcha v2。
Installation
npm install 2captcha-wrapper
Usage
您需要一个 2captcha api 密钥,您可以在此处 获取。
该模块导出 TwoCaptcha 原型。 它在构建时接受两个参数:apiKey 和 timeout, 超时参数可以省略,默认为180000毫秒;
该对象包含用于获取 google recaptcha 的验证码 id/token 的 solve 方法。
solve 方法在成功时返回一个包含请求 ID 和令牌的对象。 失败时返回 null 并报告 错误的验证码。
获得令牌后,您可以将它与您的 http 请求一起发送,或者如果您正在运行 puppeteer/selenium,则可以在页面中设置它。
id 可用于使用 reportGood/reportBad 方法报告好/坏验证码。
获取siteKey: 打开网页,查看源代码,ctrl+f "data-sitekey"。
TwoCaptcha = require('2captcha-wrapper');
const apiKey = '123tyg231yg123v32g123u'; //Your 2captcha api key
const captchaTimeout = 180000; //The maximum amount of time (ms) to wait for the captcha to be solved.
const siteCaptcha = {
siteKey: 'uadsuadsuyasduvsduv', //The url's siteKey
url: 'www.example.com', //The url in which the captcha appears
invisible: false, //Whether or not the captcha is invisible
}
async function main() {
var tcaptcha = new TwoCaptcha(apiKey, captchaTimeout);
var captchaToken = await tcaptcha.solve(siteCaptcha);
console.log('Got token!');
console.log(captchaToken);
}
main();
Author
Ícaro Augusto
- https://icaroaugusto.com
- Discord: IcaroAugusto#3303
Changelogs
1.0.0
创建。
NODE.js 2captcha wrapper
This is a node.js module for solving google's recaptcha v2 using the 2captcha service.
Installation
npm install 2captcha-wrapper
Usage
You will need a 2captcha api key, which you can get here.
The module exports the TwoCaptcha prototype. It accepts two parameters on construction: apiKey and timeout, the timeout parameter can be ommited, defaulting to 180000 milliseconds;
The object contains the solve method that should be used to get the captcha id/token for google recaptcha.
The solve method, when successful, returns an object containing the request id and token. On failure it returns null and reports the bad captcha.
After getting the token, you can send it with your http request or set it in the page if you're running puppeteer/selenium.
The id can be used to report good/bad captcha using the reportGood/reportBad methods.
To get the siteKey: Open the webpage, view source, ctrl+f "data-sitekey".
TwoCaptcha = require('2captcha-wrapper');
const apiKey = '123tyg231yg123v32g123u'; //Your 2captcha api key
const captchaTimeout = 180000; //The maximum amount of time (ms) to wait for the captcha to be solved.
const siteCaptcha = {
siteKey: 'uadsuadsuyasduvsduv', //The url's siteKey
url: 'www.example.com', //The url in which the captcha appears
invisible: false, //Whether or not the captcha is invisible
}
async function main() {
var tcaptcha = new TwoCaptcha(apiKey, captchaTimeout);
var captchaToken = await tcaptcha.solve(siteCaptcha);
console.log('Got token!');
console.log(captchaToken);
}
main();
Author
Ícaro Augusto
- https://icaroaugusto.com
- Discord: IcaroAugusto#3303
Changelogs
1.0.0
Created.