0.1.5 • Published 2 years ago

anti-captcha-pingback v0.1.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Intro

This package is for use with Anti-Captcha.

This package aims to get you setup with an Anti-Captcha pingback server solution with just a few lines of code.

This package uses a pingback (callback url) rather than constantly asking anti-captcha's servers if they are ready yet. This will save bandwidth and computational resources for both you and Anti-Captcha.

Anti-Captcha will send a request to your pingback port when they have the solution to your captcha.

Prerequisites

  1. an Anti-Captcha account and api key
  2. port 8080 or other specified port open on your server or forwarded to your computer
    1. The open port is needed to get the pingback/callback from anti-captcha's servers

Getting Started

First add the package to your project using npm

npm i anti-captcha-pingback

Next replace <Your API Key Here> in the following code with your api key from Anti-Captcha

const ac = require("anti-captcha-pingback")
const anti_captcha = new ac.AntiCaptchaPingback("<Your API Key Here>");

async function main() {
    let result = await anti_captcha.solve_image_captcha("./captcha.png")
    console.log(result);
    await anti_captcha.close(); //close when done
}

main();

The result object will look like below if everything worked

if Anti-Captcha responds with an error the promise will reject

Output

{
  "rawResponseObject": {
    "taskId": 0,
    "errorId": 0,
    "status": "ready",
    "solution": {
      "text": "PRNU",
      "url": ""
    },
    "cost": "0.00070",
    "ip": "",
    "createTime": 0,
    "endTime": 0,
    "solveCount": 0
  },
  "solution": "PRNU"
}

Getting The Solution

While we provide the "rawResponseObject" from Anti-Captcha, we have normalized the solution of most of our solve functions to be able to jump right to the solution using the code below. This is the method we recommend using to solve your captchas.

GeeTestTask has 3 different solutions

const ac = require("anti-captcha-pingback")
const anti_captcha = new ac.AntiCaptchaPingback("<Your API Key Here>");

async function main() {
    let result = await anti_captcha.solve_image_captcha("./captcha.png")
    console.log(result.solution);
    await anti_captcha.close(); //close when done
}

main();

output

"PRNU"

Port

you can set the port to any number you want to use

const ac = require("anti-captcha-pingback")
const anti_captcha = new ac.AntiCaptchaPingback("<Your API Key Here>", 8085); //use port 8085 instead of 8080

async function main() {
    let result = await anti_captcha.solve_image_captcha("./captcha.png")
    console.log(result.solution);
    await anti_captcha.close(); //close when done
}

main();

IP

This package will get your public ip automatically on launch, but if you already know the ip of your server you can specifiy it as the 3rd parameter when creating the AntiCaptchaPingback object.

replace ip here with the ip you want the pingback to be sent to, this request needs to end up comming back to the pingback server of this package or it will not work however.

const ac = require("anti-captcha-pingback")
const anti_captcha = new ac.AntiCaptchaPingback("<Your API Key Here>", 8080, "ip here"); //set ip

async function main() {
    let result = await anti_captcha.solve_image_captcha("./captcha.png")
    console.log(result.solution);
    await anti_captcha.close(); //close when done
}

main();

RecaptchaV2 example

const ac = require("anti-captcha-pingback")
const anti_captcha = new ac.AntiCaptchaPingback("<Your API Key Here>")

async function main() {
    let result = await anti_captcha.solve_recaptchaV2("https://anti-captcha.com/tutorials/v2-textarea", "6LfydQgUAAAAAMuh1gRreQdKjAop7eGmi6TrNIzp")
    console.log(result.solution);
    await anti_captcha.close(); //close when done
}

main();

output

03AGdBq25WOtiVaKZA26E1Gw224aC4bcOHfSNt_m...

Base64 captcha

let result = await anti_captcha.solve_base64_captcha("base64 here")

RecaptchaV2

let result = await anti_captcha.solve_recaptchaV2("site url here", "sitekey here")

RecaptchaV2Enterprise

let result = await anti_captcha.solve_recaptchaV2Enterprise("site url here", "sitekey here")

RecaptchaV3

let result = await anti_captcha.solve_recaptchaV3("url", "key", minScore)

HCaptcha

let result = await anti_captcha.solve_hcaptcha("url", "key", "userAgent")

FunCaptcha

let result = await anti_captcha.solve_funCaptcha("url", "key")

GeeTestCaptchaV3

let result = await anti_captcha.solve_geeTestTaskV3("url", "gt", "challenge")

GeeTestCaptchaV4

let result = await anti_captcha.solve_geeTestTaskV4("url", "gt")

Extra Options

if you need to pass any extra options, you can pass an options object as an optional parameter to the solve_ functions.

let result = await anti_captcha.solve_image_captcha("./captcha.png", {case: false, math: true})

Get Balance

let balance = await anti_captcha.get_balance();
console.log(balance); // 12.3456

Get taskId before solution is ready

let result = undefined;
let taskId = new Promise((resolve, reject) => {
    result = anti_captcha.solve_base64_captcha("base64 here", {}, resolve)
})
taskId = await taskId;
console.log(taskId); //123456789
result = await result;

Future

May or maynot add these features in the future, just some ideas

  1. better way of getting back taskId
  2. error handling, right now you need to handle any thrown errors
  3. non pingback only
  4. api limiting, right now you need to handle any api limit errors
  5. proxy support, only supports proxyless currently
0.1.2

2 years ago

0.1.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.5

2 years ago

0.1.0

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago