node_two_captcha
Version:
Node.js package for easy integration with 2Captcha API (Captcha Solver as a Service)
156 lines (112 loc) • 6.29 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
<section>
<article><h1>Node TwoCaptcha</h1><p><a href="https://badge.fury.io/js/%40infosimples%2Fnode_two_captcha"><img src="https://badge.fury.io/js/%40infosimples%2Fnode_two_captcha.svg" alt="npm version"></a>
<img src="https://img.shields.io/github/license/infosimples/node_two_captcha.svg?style=flat" alt="">
<a href="https://codeclimate.com/github/infosimples/node_two_captcha/maintainability"><img src="https://api.codeclimate.com/v1/badges/78356b38afac3763f1fe/maintainability" alt="Maintainability"></a></p>
<p>Node TwoCaptcha is a Javascript package for 2Captcha -
<a href="http://2captcha.com/?from=1025109">2Captcha.com</a>.</p>
<h2>Installation</h2><p>Just run:</p>
<pre class="prettyprint source"><code>npm install @infosimples/node_two_captcha</code></pre><p>JSDoc documentation can be found at https://infosimples.github.io/node_two_captcha/</p>
<h2>Usage</h2><h3>1. Create a client</h3><pre class="prettyprint source lang-javascript"><code>// Import module
const Client = require('@infosimples/node_two_captcha');
// Declare your client
client = new Client('your_2captcha_key', {
timeout: 60000,
polling: 5000,
throwErrors: false});</code></pre><p>The first parameter of the <code>TwoCaptchaClient</code> constructor is your API key from
2Captcha. The other parameters are:</p>
<ul>
<li><code>timeout</code>: Time (milliseconds) to wait before giving up on waiting for a
captcha solution.</li>
<li><code>polling</code>: Time (milliseconds) between polls to 2captcha server. 2Captcha
documentation suggests this time to be at least 5 seconds, or you might get
blocked.</li>
<li><code>throwErrors</code>: Whether the client should throw errors or just log the errors.</li>
</ul>
<h3>2. Solve a captcha</h3><h4>Image captcha</h4><pre class="prettyprint source lang-javascript"><code>client.decode({
url: 'http://bit.ly/1xXZcKo'
}).then(function(response) {
console.log(response.text);
});
> infosimples</code></pre><p><code>decode</code> is an async function. Valid parameters for <code>decode</code> function are:</p>
<ul>
<li><code>base64</code>: An already base64-coded image.</li>
<li><code>buffer</code>: A buffer object of a binary image.</li>
<li><code>path</code>: The path for a system-stored image.</li>
<li><code>url</code>: Url for a web-located image.</li>
</ul>
<p>The returned value will be a <code>Captcha</code> object. Its properties are:</p>
<ul>
<li><code>apiResponse</code>: Complete API response body for captcha request.</li>
<li><code>id</code>: Captcha ID, as provided from 2Captcha.</li>
<li><code>text</code>: Text from captcha.</li>
<li><code>coordinates()</code>: If the captcha sent was a image, this function returns the
coordinates (X, Y) clicked.</li>
<li><code>indexes()</code>: If the captcha sent was tile-like, this function returns the
indexes of the clicks on an array.</li>
</ul>
<h4>ReCaptcha v2</h4><pre class="prettyprint source lang-javascript"><code>client.decodeRecaptchaV2({
googlekey: 'the_key_extracted from the page',
pageurl: 'https://www.google.com/recaptcha/api2/demo'
}).then(function(response) {
console.log(response.text);
});
>jTfh3o9uqafa-u5RtYofHHo2uDk0T78f78HvttFGYft8pG3wuhd-UHAIy271bQXPeUNRm...</code></pre><p><code>decodeRecaptchaV2</code> is an async function. The parameters for <code>decodeRecaptchaV2</code>
function are:</p>
<ul>
<li><code>googlekey</code>: The google key for the ReCaptcha.</li>
<li><code>pageurl</code>: The URL where the ReCaptcha is.</li>
</ul>
<h3>3. Retrieve a previously solved captcha</h3><pre class="prettyprint source lang-javascript"><code>// 61086191138 is the ID of a previously sent Captcha
client.captcha('61086191138').then(function(response){
console.log(response);
});
> Captcha {
_id: '61086191138',
_apiResponse: 'OK|infosimples',
_text: 'infosimples' }</code></pre><h3>4. Report incorrectly solved captcha for refund</h3><pre class="prettyprint source lang-javascript"><code>client.report('61086191138').then(function(response) {
console.log(response);
});
// Returns whether the report was received or not
> true</code></pre><blockquote>
<p>Warning: do not abuse on this method, otherwise you may get banned</p>
</blockquote>
<h3>5. Get usage statistics for a specific date</h3><pre class="prettyprint source lang-javascript"><code>let date = new Date('2019-02-04');
client.stats(date).then(function(response) {
console.log(response);
});
// Returns an XML string with your usage statistics
> <?xml version="1.0"?><response><stats dateint="1549227600" date="2019-02-04" hour="00"><volume>0</volume><money>0</money></stats><stats dateint="1549231200" date="2019-02-04" hour="01"><volume>0</volume><money>0</money></stats>...</code></pre><h3>6. Get your 2Captcha account balance</h3><pre class="prettyprint source lang-javascript"><code>client.balance().then(function(response) {
console.log(response);
});
// Returns a float with your account balance in USD
> 3.75371</code></pre></article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Captcha.html">Captcha</a></li><li><a href="HTTPRequest.html">HTTPRequest</a></li><li><a href="TwoCaptchaClient.html">TwoCaptchaClient</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Feb 11 2019 10:38:09 GMT-0200 (Brasilia Summer Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>