use ocr to identifier page content
This commit is contained in:
@@ -11,6 +11,7 @@ const {
|
||||
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
||||
const SlidingCaptchaSolver = require("./SlidingCaptchaSolver");
|
||||
const {de} = require("yarn/lib/cli");
|
||||
const OCRChecker = require("./OCRChecker");
|
||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
const BLANK_URL = "about:blank"
|
||||
@@ -321,8 +322,8 @@ class CommandorPage {
|
||||
}
|
||||
}
|
||||
|
||||
async clickValid(page) {
|
||||
await this.saveCookies()
|
||||
async clickValid() {
|
||||
// await this.saveCookies()
|
||||
await delay(getRandomWaitTime())
|
||||
try {
|
||||
if (!this.page.isClosed()) {
|
||||
@@ -337,9 +338,15 @@ class CommandorPage {
|
||||
// remove debug flag
|
||||
// const validElement = await page.$('.btn');
|
||||
console.log("will click on valid button")
|
||||
console.log("will click on valid button")
|
||||
console.log("will click on valid button")
|
||||
this.page.evaluate(() => {
|
||||
document.getElementsByClassName("btn")[0].click();
|
||||
})
|
||||
// this.browser.disconnect();
|
||||
await delay(2000);
|
||||
let ocrChecker = new OCRChecker(this.device, this.contact)
|
||||
await ocrChecker.get_result()
|
||||
} catch (e) {
|
||||
log(e)
|
||||
}
|
||||
@@ -360,6 +367,7 @@ class CommandorPage {
|
||||
let pageContent = await page.content()
|
||||
let hasCaptcha = pageContent.includes("g-recaptcha-response")
|
||||
if (hasCaptcha) {
|
||||
// await this.browser.disconnect()
|
||||
await this.clickCheckbox()
|
||||
await delay(1000)
|
||||
this.captchaSolver = new SolveCaptcha(page);
|
||||
@@ -511,7 +519,7 @@ class CommandorPage {
|
||||
} else {
|
||||
log("audioBtn not found")
|
||||
console.log("audioBtn not found")
|
||||
console.log("we are blocked")
|
||||
logWithDevice("we are blocked", this.device)
|
||||
await this.resetBrowser()
|
||||
}
|
||||
}
|
||||
@@ -533,7 +541,7 @@ class CommandorPage {
|
||||
// log("onResponse with url:" + response.url())
|
||||
// log("onResponse with url:" + response.body())
|
||||
if (rex.test(response.url())) {
|
||||
log("rdv url found:" + response.url())
|
||||
logWithDevice("rdv url found:" + response.url(), this.device)
|
||||
// save cookies
|
||||
await this.saveCookies();
|
||||
await this.push_message_to_db(PublishType.SUCCESS, response.url())
|
||||
@@ -591,12 +599,26 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
async clickCheckbox() {
|
||||
// try {
|
||||
// // let errorItem = await this.page.click("#recaptcha-anchor > div.recaptcha-checkbox-border")
|
||||
// await this.page.$('[title="reCAPTCHA"]').getByRole('checkbox', {name: 'I\'m not a robot'}).click();
|
||||
// } catch (e) {
|
||||
// log(e);
|
||||
// }
|
||||
try {
|
||||
// let errorItem = await this.page.click("#recaptcha-anchor > div.recaptcha-checkbox-border")
|
||||
await this.page.waitForSelector("iframe")
|
||||
let elementHandle = await this.page.$('[title="reCAPTCHA"]')
|
||||
const iframe = await elementHandle.contentFrame()
|
||||
await iframe.click("#recaptcha-anchor > div.recaptcha-checkbox-border")
|
||||
// // .getByRole('checkbox', {name: 'I\'m not a robot'})
|
||||
// if (enCheckbox) {
|
||||
// enCheckbox.click()
|
||||
// } else {
|
||||
// let frCheckbox = await this.page.$('[title="reCAPTCHA"]').getByRole('checkbox', {name: 'Je ne suis pas un robot'})
|
||||
// if (frCheckbox) {
|
||||
// frCheckbox.click()
|
||||
// } else {
|
||||
// console.log("recaptcha checkbox not found")
|
||||
// }
|
||||
// }
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
|
||||
async handleError(errorContent) {
|
||||
|
||||
Reference in New Issue
Block a user