CAPTCHAFORUM
Administrator
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
Code:
// 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.
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
Code:
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
Code:
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'
Code:
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));
Documentation https://github.com/bogdan0083/rucaptcha-solver