@cybersify/solvecaptcha
v0.0.10
Published
This is a boilerplate of an Apify actor.
Downloads
1
Maintainers
Readme
Install
You can find some snippet code to resolve captchas with solvecaptcha.net
cd anticaptcha folder
npm i @cybersify/solvecaptcha
Usage
// this illustrate available captcha on site https://solvecaptcha.net
const { solveCaptchaV2 } = require("@cybersify/solvecaptcha")
const params = {
key: 'x|XOWpjuDQYBHIOqXr0X1bYuYkMJKsWWPO4xxxxxxxxx', // account key at solvedcaptcha.net
method: 'RecaptchaV2TaskProxyless',
page_url: 'https://ct.captcha-xxxx.com', // url destination
site_key: '6LccSjEUAAAAANCPhaM2c-WiRxCZ5CzsjR_xxx', // key site google Captcha,
};
(async () => {
try {
// solve the google captcha with API
console.log("* Waiting g-recaptcha-reponse");
const token = await solveCaptchaV2(params, api);
console.log('* Receive g-recaptcha-reponse: ' + token);
// unsccessful case
if (token.includes('ERROR') || token.includes('CAPCHA_NOT_READY')){
process.exit(1)
}
} catch (error) {
console.log(error);
}
})();
// this illustrate available captcha on site https://solvecaptcha.net
const { solveGeeTest } = require("@cybersify/solvecaptcha")
const puppeteer = require('puppeteer');
const Apify = require('apify');
const params = {
key: 'x|XOWpjuDQYBHIOqXr0X1bYuYkMJKsWWPO4xxxxxxxxx', // account key at solvedcaptcha.net
method: 'GeeTestTaskProxyless',
gt:'1e505deed3832c02c96ca5abe70dxxxx',
page_url: 'https://www.xxxxxsales.com.au/',
geetestApiServerSubdomain:'api-na.geetest.com'
};
(async () => {
const browser = await puppeteer.launch({
headless: false,
slowMo: 250,
args: [
'--disable-web-security',
'--disable-features=IsolateOrigins,site-per-process',
'--user-data-dir=./.config/google-chrome'
]
});
const page = await browser.newPage();
try {
await resolveGeetestCaptcha(page,params);
} catch (err) {
console.log('ERR:', err.message);
await browser.close();
process.exit(1);
} finally {
await browser.close();
process.exit(0);
}
})();
async function resolveGeetestCaptcha(page , params){
await Apify.utils.puppeteer.blockRequests(page, {
extraUrlPatterns: ['api.geetest.com', 'api-na.geetest.com'],
});
await page.goto(params.page_url, {waitUntil: 'networkidle0'});
let content = await page.content();
// waiting loaded iFrame DataDome
await page.waitForSelector('iframe');
const iframe = page.mainFrame().childFrames()[0];
let str = await iframe.content();
let arr = str.split(",");
for (i=0; i < arr.length ; i ++){
if(arr[i].includes(" challenge:") > 0){
arr_challenge = arr[i].split(":");
params.challenge = arr_challenge[1].replace(/[^0-9a-zA-Z]/g,'');
}
}
if(params.challenge != null && params.challenge != undefined){
console.log("*geetest_form: True");
}else{
console.log("*geetest_form: False");
}
if(params.challenge != null && params.challenge != undefined){
params.websiteURL=params.page_url;
const token = await solveGeeTest(params);
console.log(token);
// unsccessful case
if (token.challenge == undefined || token.challenge == null){
await browser.close();
process.exit(1)
}
const elementHandle = await page.$('iframe');
const frameContentFrame = await elementHandle.contentFrame();
await frameContentFrame.evaluate(async (captchaResult) => {
geetestResponse = {
geetest_challenge: captchaResult.challenge,
geetest_validate: captchaResult.validate,
geetest_seccode: captchaResult.seccode,
};
captchaCallback(); // maybe use different name
}, token);
}
}
Motivation
These days captchas are unfortunately everywhere, with reCAPTCHA having the biggest "market share" in that space (> 80%). The situation got really bad, with privacy minded users (tracking blocker, VPNs) being penalized heavily and having to solve a lot of reCAPTCHA challenges constantly while browsing the web.
These small codes allow us to get automatically google token from Solvecaptcha Service and bypass google's protection. It is very important for crawler's activites.