npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rucaptcha-solver

v1.1.9

Published

Yet another rucaptcha client

Downloads

106

Readme

Rucaptcha-solver - rucaptcha client for Node js

Rucaptcha client for small/big captcha with Promises and async/await support

Installation

rucaptcha-solver requires Node v7.0.0 or greater

npm i rucaptcha-solver

How to use

// require solver module
const Solver = require('rucaptcha-solver');

// create new Solver instance
const solver = new Solver({
  apiKey: '1abc234de56fab7c89012d34e56fa7b8' // Required
});

// async/await example. For example with promises check "Examples" link above
(async () => {

  // wikipedia link to captcha
  const captchaUrl = 'https://upload.wikimedia.org/wikipedia/commons/6/69/Captcha.jpg';

  // solve captcha
  const { id, answer } = await solver.solve(captchaUrl);

  console.log(`Your captcha answer is ${answer}`);
  console.log(`Your captcha id is ${id}`);

})();

Constructor

new Solver(settings)

Constructor settings

  • apiKey <String> required - Api key from your rucaptcha.com account. Should be length of 32 symbols.

  • retryInterval <Number> optional - retry interval for making request to get captcha in milliseconds. Default value is 3000 ms. Number shouldn't be less then 2000 ms, because you have a chance to get banned by rucaptcha server.

Available methods

solver.solve(imgPath, options) - solves captcha image. Image gets downloaded from imgPath.

  • imgPath <String> required - Path to captcha image. Can be url or local path
  • params <Object> optional - Additional params with POST request to help solve captcha more easily. All available parameters can be found here
  • returns <Promise> which resolves to <Object> with id and answer

Here's example with parameters:

  const Solver = require('rucaptcha-solver');
  const solver = new Solver({ apiKey: 'some-api-key' });

  solver.solve('http://pathtoimage.com/captcha.jpg', {     
    // captcha consists of two or more words
    phrase: 1,
    // captcha uses only latin characters
    language: 2
  })
  // resolves
  .then(({ id, answer }) => console.log(`captcha answer: ${answer}`))
  // handle error
  .catch(error => console.error(error));

solver.getBalance() - get balance on your account

  • returns <Promise> which resolves to <Number> balance

Example:

  const Solver = require('rucaptcha-solver');
  const solver = new Solver({ apiKey: 'some-api-key' });

  solver.getBalance()
    .then(balance => console.log(`your balance: ${balance}`))
    // handle error
    .catch(error => console.error(error));

solver.report(captchaId) - report user if captcha answer is incorrect

  • captchaId <Number> required - Captcha id. solve method return answer to captcha and captchaId
  • returns <Promise> which resolves to <String> 'OK_REPORT_RECORDED'

Example:

  const Solver = require('rucaptcha-solver');
  const solver = new Solver({ apiKey: 'some-api-key' });

  // solve captcha first
  solver.solve('http://pathtoimage.com/captcha.jpg')
    .then(({ id, answer }) => {
      // do something with answer...
      // ...
      // if we received incorrect answer, we can report user
      return solver.report(id);
    })
    .then(msg => console.log(msg))
    // handle error
    .catch(error => console.error(error));

Examples

Example with async/await:

const Solver = require('rucaptcha-solver');

// create new Solver instance
const solver = new Solver({
  apiKey: 'YOUR_API_KEY',
  retryInterval: 3000
});

(async () => {
  try {
    // get captcha answer
    const { id, answer } = await solver.solve('https://upload.wikimedia.org/wikipedia/commons/6/69/Captcha.jpg');
    console.log(`Captcha answer is ${answer}`);
    console.log(`Your captcha id is ${id}`);

    // we can get balance from our account if we want
    const balanceNum = await solver.getBalance();
    console.log(`our balance is ${balanceNum}`);

    // ...
    // we can report user if we received incorrect captcha answer
    // const success = await solver.report(id);
  } catch (e) {
    // handle error
    console.error(e);
  }
})();

Example with Promises

const Solver = require('rucaptcha-solver');

// create new Solver instance
const solver = new Solver({
  apiKey: 'YOUR_API_KEY'
});

// solve captcha
solver.solve('https://upload.wikimedia.org/wikipedia/commons/6/69/Captcha.jpg')
  .then(({id, answer}) => {
    console.log(`Captcha answer is ${answer}`);
    console.log(`Your captcha id is ${id}`);

    // we can get balance from our account if we want
    return solver.getBalance();
  }))
  .then(balanceNum => console.log(`Your balance: ${balanceNum}`))

  // handle error
  .catch(e => console.error(e));

Why

There are few Rucaptcha clients for node js out there, but some of them are deprecated and don't support promises and async/await. This client solves all the problems.