Update reCaptcha solving examples

master
pro-src 2019-09-14 00:22:31 -05:00
parent e5428dbd8e
commit 02e55d3e44
No known key found for this signature in database
GPG Key ID: 7D149CD9097DFAB4
2 changed files with 4 additions and 4 deletions

View File

@ -8,7 +8,7 @@ const cloudscraper = require('../..').defaults({ onCaptcha: handler, headers });
function handler (options, { captcha }) {
return new Promise((resolve, reject) => {
// Here you do some magic with the siteKey provided by cloudscraper
console.error('The url is "' + captcha.url + '"');
console.error('The url is "' + captcha.uri.href + '"');
console.error('The site key is "' + captcha.siteKey + '"');
// captcha.form['g-recaptcha-response'] = /* Obtain from your service */
reject(new Error('This is a dummy function.'));
@ -16,9 +16,9 @@ function handler (options, { captcha }) {
}
// An example handler with destructuring arguments
function alternative (options, { captcha: { url, siteKey } }) {
function alternative (options, { captcha: { uri, siteKey } }) {
// Here you do some magic with the siteKey provided by cloudscraper
console.error('The url is "' + url + '"');
console.error('The url is "' + uri.href + '"');
console.error('The site key is "' + siteKey + '"');
return Promise.reject(new Error('This is a dummy function'));
}

View File

@ -7,7 +7,7 @@ function solveReCAPTCHA (url, sitekey, callback) {
function onCaptcha (options, response, body) {
const captcha = response.captcha;
// solveReCAPTCHA is a method that you should come up with and pass it href and sitekey, in return it will return you a reponse
solveReCAPTCHA(response.request.uri.href, captcha.siteKey, (error, gRes) => {
solveReCAPTCHA(captcha.uri.href, captcha.siteKey, (error, gRes) => {
// eslint-disable-next-line no-void
if (error) return void captcha.submit(error);
captcha.form['g-recaptcha-response'] = gRes;