can slide when blocked by captcha

This commit is contained in:
2023-03-04 13:28:10 +01:00
parent c363620b65
commit 46af10ceac
6 changed files with 154 additions and 14 deletions
+19 -11
View File
@@ -7,6 +7,7 @@ const {
shell
} = require('electron')
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
const SlidingCaptchaSolver = require("./SlidingCaptchaSolver");
// const RDV_URL = "http://192.168.0.41:8000/test_appointment.html"
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
const BLANK_URL = "about:blank"
@@ -36,7 +37,7 @@ const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
const REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
const DEFAULT_STORE = 'faubourg';
const searchTexts = ['hermes+rdv', 'hermes+rendezvous', 'hermes+appointment', 'hermes+appointment+online', 'appointment+hermes', 'hermes+rendez+vous','hermes+rendez+vous+paris', 'online+appointment+hermes', 'hermes+online+appointment', 'paris+hermes+online+appointment']
const searchTexts = ['hermes+rdv', 'hermes+rendezvous', 'hermes+appointment', 'hermes+appointment+online', 'appointment+hermes', 'hermes+rendez+vous', 'hermes+rendez+vous+paris', 'online+appointment+hermes', 'hermes+online+appointment', 'paris+hermes+online+appointment']
function delay(delayInMs) {
return new Promise(resolve => {
@@ -96,7 +97,6 @@ class CommandorPage {
try {
const item = searchTexts[Math.floor(Math.random() * searchTexts.length)];
await this.page.goto("https://www.google.com/search?q=" + item + "&lr=lang_en", {timeout: 90 * 1000});
// await this.page.goto(RDV_URL, {timeout: 90 * 1000});
} catch (e) {
log(e)
this.isTerminated = true
@@ -117,7 +117,9 @@ class CommandorPage {
this.page.locator(':nth-match(:text("Online Appointment"), 1)').click()
} catch (e) {
log(e)
this.isTerminated = true
if (!this.page.url().includes(RDV_URL)) {
this.isTerminated = true;
}
}
let cancel
@@ -386,20 +388,26 @@ class CommandorPage {
async checkAudioBtn() {
let isBlocked = await this.isBlocked()
if (!isBlocked) {
let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button");
log("audioBtn found")
audioBtn.click()
let captchaSolver = new GeoCaptchaSolver(this.page, this.device, this.isTerminated)
await captchaSolver.solve((isSuccessful) => {
if (!isSuccessful) {
this.isTerminated = true
//try to sliding capthca at first
let slidingCaptchaSolver = new SlidingCaptchaSolver(this.device);
await slidingCaptchaSolver.solve(this.page, async (isSuccessful) => {
let isAlwaysBlocked = await this.isBlocked();
if (isAlwaysBlocked) {
let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button");
log("audioBtn found")
audioBtn.click()
let captchaSolver = new GeoCaptchaSolver(this.page, this.device, this.isTerminated)
await captchaSolver.solve((isSuccessful) => {
if (!isSuccessful) {
this.isTerminated = true
}
})
}
})
} else {
log("audioBtn not found")
console.log("audioBtn not found")
console.log("we are blocked")
//
await this.resetBrowser()
}
}