@infosimples/node_two_captcha
Advanced tools
Comparing version 1.1.0 to 1.2.0
/*global document */ | ||
(() => { | ||
const source = document.getElementsByClassName('prettyprint source linenums'); | ||
let i = 0; | ||
let lineNumber = 0; | ||
let lineId; | ||
let lines; | ||
let totalLines; | ||
let anchorHash; | ||
(function() { | ||
var source = document.getElementsByClassName('prettyprint source linenums'); | ||
var i = 0; | ||
var lineNumber = 0; | ||
var lineId; | ||
var lines; | ||
var totalLines; | ||
var anchorHash; | ||
@@ -18,3 +18,3 @@ if (source && source[0]) { | ||
lineNumber++; | ||
lineId = `line${lineNumber}`; | ||
lineId = 'line' + lineNumber; | ||
lines[i].id = lineId; | ||
@@ -21,0 +21,0 @@ if (lineId === anchorHash) { |
{ | ||
"name": "@infosimples/node_two_captcha", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Node.js package for easy integration with 2Captcha API (Captcha Solver as a Service)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -119,2 +119,23 @@ # Node TwoCaptcha | ||
#### hCaptcha | ||
```javascript | ||
client.decodeHCaptcha({ | ||
sitekey: 'the_key_extracted_from_the_page', | ||
pageurl: 'https://www.site.with.hcaptcha/example', | ||
}).then(function(response) { | ||
console.log(response.text); | ||
}); | ||
>P0_eyJ0eXAiIoJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXNza2V5IjoiczHiam4vKzZnb... | ||
``` | ||
`decodeHCaptcha` is an async function. The parameters for `decodeHCaptcha` | ||
function are: | ||
- `sitekey`: The site key for the hCaptcha. | ||
- `pageurl`: The URL where the hCaptcha is. | ||
- `invisible`: optional (Boolean) switch for invisible ReCaptcha, default | ||
is `false`. | ||
### 3. Retrieve a previously solved captcha | ||
@@ -121,0 +142,0 @@ |
@@ -182,2 +182,39 @@ 'use strict'; | ||
/** | ||
* Sends a hCaptcha and polls for its response | ||
* | ||
* @param {Object} options Parameters for the request | ||
* @param {string} options.sitekey The site key of the hCaptcha | ||
* @param {string} options.pageurl The URL where the hCaptcha is | ||
* @param {boolean} options.invisible Invisible hCaptcha | ||
* @return {Promise<Captcha>} Promise for a Captcha object | ||
*/ | ||
async decodeHCaptcha(options = {}) { | ||
let startedAt = Date.now(); | ||
if (options.sitekey === '') this._throwError('Missing sitekey parameter'); | ||
if (options.pageurl === '') this._throwError('Missing pageurl parameter'); | ||
let upload_options = { | ||
method: 'hcaptcha', | ||
sitekey: options.sitekey, | ||
pageurl: options.pageurl, | ||
invisible: options.invisible ? 1 : 0, | ||
}; | ||
let decodedCaptcha = await this._upload(upload_options); | ||
// Keep pooling untill the answer is ready | ||
while (!decodedCaptcha.text) { | ||
await this._sleep(Math.max(this.polling, 10)); // Sleep at least 10 seconds | ||
if (Date.now() - startedAt > this.timeout) { | ||
this._throwError('Captcha timeout'); | ||
return; | ||
} | ||
decodedCaptcha = await this.captcha(decodedCaptcha.id); | ||
} | ||
return decodedCaptcha; | ||
} | ||
/** | ||
* @deprecated /load.php route is returning error 500 | ||
@@ -184,0 +221,0 @@ * Get current load from 2Captcha service |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1127108
1106
194