diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index eab89e9..6a04350 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -11,8 +11,8 @@ const { const GeoCaptchaSolver = require("./GeoCaptchaSolver"); const SlidingCaptchaSolver = require("./SlidingCaptchaSolver"); const {de} = require("yarn/lib/cli"); -const RDV_URL = "http://192.168.0.44:8000/test_appointment.html" -// const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; +// 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" const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE"; @@ -125,9 +125,10 @@ class CommandorPage { log(e) } try { - // await this.setUpCookies() - await this.page.focus(':nth-match(:text("rendezvousparis"), 1)') - await this.page.click() + // let element = await this.page.$(':nth-match(:text("rendezvousparis"), 1)') + await this.page.$eval(':nth-match(:text("rendezvousparis"), 1)', el => { + el.click() + }); } catch (e) { log(e) if (!this.page.url().includes(RDV_URL)) { @@ -371,8 +372,8 @@ class CommandorPage { } async isBlocked() { - let iframeHandler = await this.page.frameLocator("body > iframe"); - let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER) + let iframeHandler = await this.page.$("body > iframe"); + let captcha_container = await iframeHandler.$(CAPTCHA_CONTAINER) let html = await captcha_container.innerHTML() console.log("audio_tag: " + html); return html.includes("You have been blocked") || html.includes("Vous avez été bloqué") || html.includes("封锁") @@ -445,37 +446,37 @@ class CommandorPage { async saveCookies() { log("saveCookies() called.") - try { - let cookies = await this.page.context().cookies(); - let cookiesInJson = []; - cookies.forEach((cookie) => { - cookiesInJson.push(JSON.stringify(cookie)) - }) - await require("fs").writeFileSync(this.contact.mail + '.txt', cookiesInJson.join('\n')); - } catch (e) { - console.log(e) - } + // try { + // let cookies = await this.page.context().cookies(); + // let cookiesInJson = []; + // cookies.forEach((cookie) => { + // cookiesInJson.push(JSON.stringify(cookie)) + // }) + // await require("fs").writeFileSync(this.contact.mail + '.txt', cookiesInJson.join('\n')); + // } catch (e) { + // console.log(e) + // } } async setUpCookies() { // load cookies from file - try { - logWithDevice("will add cookies", this.device) - const fs = require('fs'); - // let cookiesFile = fs.readFileSync('vampuka_fisherleyba@aol.com.txt', 'utf8'); - let cookiesFile = fs.readFileSync(this.contact.mail + '.txt', 'utf8'); - let cookiesList = cookiesFile.split("\n") - let cookiesListToAdd = [] - cookiesList.forEach((cookie) => { - let cookieToAdd = JSON.parse(cookie) - // if (cookieToAdd.name === "datadome") { - cookiesListToAdd.push(cookieToAdd) - // } - }) - await this.context.addCookies(cookiesListToAdd) - } catch (e) { - console.log(e) - } + // try { + // logWithDevice("will add cookies", this.device) + // const fs = require('fs'); + // // let cookiesFile = fs.readFileSync('vampuka_fisherleyba@aol.com.txt', 'utf8'); + // let cookiesFile = fs.readFileSync(this.contact.mail + '.txt', 'utf8'); + // let cookiesList = cookiesFile.split("\n") + // let cookiesListToAdd = [] + // cookiesList.forEach((cookie) => { + // let cookieToAdd = JSON.parse(cookie) + // // if (cookieToAdd.name === "datadome") { + // cookiesListToAdd.push(cookieToAdd) + // // } + // }) + // await this.context.addCookies(cookiesListToAdd) + // } catch (e) { + // console.log(e) + // } } async checkAudioBtn() { @@ -499,15 +500,15 @@ class CommandorPage { } async resolveByAudio() { - 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 - } - }) + // 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 + // } + // }) } async onResponse(response) { diff --git a/start.js b/start.js new file mode 100644 index 0000000..359a044 --- /dev/null +++ b/start.js @@ -0,0 +1,6 @@ +const {startBookWithNumbers, scheduleBookWithNumbers} = require('./src/appointment') + + +startBookWithNumbers(0, 2, "random", "./163_contacts.xlsx", true, false).then((r) => { + console.log(r) +})