add await
This commit is contained in:
+2
-1
@@ -21,7 +21,8 @@
|
|||||||
"node-xlsx": "^0.21.0",
|
"node-xlsx": "^0.21.0",
|
||||||
"playwright": "1.23.0",
|
"playwright": "1.23.0",
|
||||||
"read-ini-file": "^3.0.1",
|
"read-ini-file": "^3.0.1",
|
||||||
"winston": "^3.8.2"
|
"winston": "^3.8.2",
|
||||||
|
"yarn": "^1.22.19"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron-forge/cli": "^6.0.0-beta.66",
|
"@electron-forge/cli": "^6.0.0-beta.66",
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import {devices} from "playwright";
|
||||||
|
|
||||||
const {SolveCaptcha, TWO_CAPTCHA_CONNECTION_FAILED} = require("./SolveCaptcha");
|
const {SolveCaptcha, TWO_CAPTCHA_CONNECTION_FAILED} = require("./SolveCaptcha");
|
||||||
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
||||||
const BlackListContactPojo = require("../models/BlackListContactPojo");
|
const BlackListContactPojo = require("../models/BlackListContactPojo");
|
||||||
@@ -9,7 +11,7 @@ const {
|
|||||||
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
||||||
// const RDV_URL = "http://192.168.0.41:8000/test_appointment.html"
|
// const RDV_URL = "http://192.168.0.41:8000/test_appointment.html"
|
||||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||||
BLANK_URL = "about:blank"
|
const BLANK_URL = "about:blank"
|
||||||
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
||||||
|
|
||||||
const COUNTRY_ID = "#phone_country"
|
const COUNTRY_ID = "#phone_country"
|
||||||
@@ -34,7 +36,7 @@ const TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests"
|
|||||||
const TOO_MANY_REQUEST_ERROR_MESSAGE_FR = "Suite à un trop grand nombre de demandes"
|
const TOO_MANY_REQUEST_ERROR_MESSAGE_FR = "Suite à un trop grand nombre de demandes"
|
||||||
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
||||||
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
||||||
REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
const REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
||||||
const DEFAULT_STORE = 'faubourg';
|
const DEFAULT_STORE = 'faubourg';
|
||||||
const searchTexts = ['hermes+rdv', 'hermes+rendezvous', 'hermes+appointment', 'hermes+appointment+online', 'appointment+hermes', 'hermes+rendez+vous', 'online+appointment+hermes', 'hermes+online+appointment']
|
const searchTexts = ['hermes+rdv', 'hermes+rendezvous', 'hermes+appointment', 'hermes+appointment+online', 'appointment+hermes', 'hermes+rendez+vous', 'online+appointment+hermes', 'hermes+online+appointment']
|
||||||
|
|
||||||
@@ -121,8 +123,8 @@ class CommandorPage {
|
|||||||
let cancel
|
let cancel
|
||||||
const intervalTask = setInterval(() => {
|
const intervalTask = setInterval(() => {
|
||||||
if (this.isTerminated) {
|
if (this.isTerminated) {
|
||||||
log("request terminated, will close device")
|
log(this.device.model() + ":request terminated, will close device");
|
||||||
context.close()
|
context.close();
|
||||||
// this.page.close()
|
// this.page.close()
|
||||||
this.device.close()
|
this.device.close()
|
||||||
clearInterval(intervalTask)
|
clearInterval(intervalTask)
|
||||||
|
|||||||
@@ -34,7 +34,13 @@ async function sendRequest(fileName, callback) {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'wav',
|
'Content-Type': 'wav',
|
||||||
'Authorization': 'Bearer 97e36f7e-340e-4c02-b329-9415faee38c3'
|
'Authorization': 'Bearer 97e36f7e-340e-4c02-b329-9415faee38c3'
|
||||||
}
|
},
|
||||||
|
timeout: 30 * 1000
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err.code);
|
||||||
|
console.log(err.stack);
|
||||||
|
console.log(err.message);
|
||||||
|
callback([]);
|
||||||
})
|
})
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
let result = response.data;
|
let result = response.data;
|
||||||
@@ -60,19 +66,19 @@ class GeoCaptchaSolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async solve(onResult) {
|
async solve(onResult) {
|
||||||
console.log("solve() called.")
|
console.log(this.device.model() + ":solve() called.")
|
||||||
console.log("play audio")
|
console.log(this.device.model() + ":play audio")
|
||||||
let iframeHandler = await this.page.frameLocator("body > iframe");
|
let iframeHandler = await this.page.frameLocator("body > iframe");
|
||||||
let playAudioBtn = await iframeHandler.locator(PLAY_AUDIO_BTN_ID);
|
let playAudioBtn = await iframeHandler.locator(PLAY_AUDIO_BTN_ID);
|
||||||
try {
|
try {
|
||||||
playAudioBtn.click();
|
await playAudioBtn.click();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
await delay(4000 + getRandomWaitTime());
|
await delay(4000 + getRandomWaitTime());
|
||||||
let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER)
|
let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER)
|
||||||
let html = await captcha_container.innerHTML()
|
let html = await captcha_container.innerHTML()
|
||||||
console.log("audio_tag: " + html);
|
console.log(this.device.model() + ":audio_tag: " + html);
|
||||||
if (!html.includes("You have been blocked")) {
|
if (!html.includes("You have been blocked")) {
|
||||||
// find wav from html
|
// find wav from html
|
||||||
await this.findTextFromWavFile(html, async (number_list) => {
|
await this.findTextFromWavFile(html, async (number_list) => {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class LinkValidator {
|
|||||||
let cancel
|
let cancel
|
||||||
const intervalTask = setInterval(() => {
|
const intervalTask = setInterval(() => {
|
||||||
if (this.isTerminated) {
|
if (this.isTerminated) {
|
||||||
log("request terminated, will close device")
|
log(this.device.model() + ":request terminated, will close device")
|
||||||
context.close()
|
context.close()
|
||||||
// this.page.close()
|
// this.page.close()
|
||||||
this.device.close()
|
this.device.close()
|
||||||
@@ -106,7 +106,7 @@ class LinkValidator {
|
|||||||
let content = await currentPage.content();
|
let content = await currentPage.content();
|
||||||
let captcha_url = "geo.captcha-delivery.com/captcha";
|
let captcha_url = "geo.captcha-delivery.com/captcha";
|
||||||
if (content.toString().includes(captcha_url)) {
|
if (content.toString().includes(captcha_url)) {
|
||||||
log("发现datadome");
|
log(this.device.model() + ":发现datadome");
|
||||||
await this.checkAudioBtn();
|
await this.checkAudioBtn();
|
||||||
} else {
|
} else {
|
||||||
if (content.includes(CONFIRMED_MESSAGE) || content.includes(CONFIRMED_MESSAGE_FR) || content.includes(CONFIRMED_MESSAGE_CN)) {
|
if (content.includes(CONFIRMED_MESSAGE) || content.includes(CONFIRMED_MESSAGE_FR) || content.includes(CONFIRMED_MESSAGE_CN)) {
|
||||||
@@ -129,10 +129,10 @@ class LinkValidator {
|
|||||||
let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button");
|
let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button");
|
||||||
let isBlocked = await this.isBlocked()
|
let isBlocked = await this.isBlocked()
|
||||||
if (!isBlocked) {
|
if (!isBlocked) {
|
||||||
log("audioBtn found")
|
log(this.device.model() + ":audioBtn found")
|
||||||
if (!this.isTerminated) {
|
if (!this.isTerminated) {
|
||||||
try {
|
try {
|
||||||
audioBtn.click()
|
await audioBtn.click()
|
||||||
let captchaSolver = new GeoCaptchaSolver(this.page, this.device, this.isTerminated)
|
let captchaSolver = new GeoCaptchaSolver(this.page, this.device, this.isTerminated)
|
||||||
await captchaSolver.solve((isSuccessful) => {
|
await captchaSolver.solve((isSuccessful) => {
|
||||||
if (!isSuccessful) {
|
if (!isSuccessful) {
|
||||||
@@ -148,7 +148,6 @@ class LinkValidator {
|
|||||||
log("audioBtn not found")
|
log("audioBtn not found")
|
||||||
console.log("audioBtn not found")
|
console.log("audioBtn not found")
|
||||||
console.log("we are blocked")
|
console.log("we are blocked")
|
||||||
//
|
|
||||||
await this.resetBrowser()
|
await this.resetBrowser()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user