From c687b92c1c2a42dc23c02802f59bdbe6f932989f Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Mon, 6 Mar 2023 19:53:43 +0100 Subject: [PATCH 01/16] check recaptcha before calling 2captcha --- src/workers/CommandorPage.js | 44 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index f9ae6fd..0bdd8ad 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -7,7 +7,7 @@ const { shell } = require('electron') const GeoCaptchaSolver = require("./GeoCaptchaSolver"); -// const RDV_URL = "http://192.168.0.41:8000/test_appointment.html" +// const RDV_URL = "http://192.168.0.13: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"; @@ -312,27 +312,33 @@ class CommandorPage { await this.push_message_to_queue(PublishType.SUCCESS) return } - this.captchaSolver = new SolveCaptcha(page); - await this.captchaSolver.start((solution) => { - log("solution is: " + solution); - if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) { - try { - if (!page.isClosed()) { - page.evaluate((solution) => { - let element = document.getElementById("g-recaptcha-response"); - if (element != null) - document.getElementById("g-recaptcha-response").innerHTML = solution; - }, solution) - this.clickValid(); + //check whether there is captcha + let hasCaptcha = await page.isVisible("g-recaptcha-response") + if (hasCaptcha) { + this.captchaSolver = new SolveCaptcha(page); + await this.captchaSolver.start((solution) => { + log("solution is: " + solution); + if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) { + try { + if (!page.isClosed()) { + page.evaluate((solution) => { + let element = document.getElementById("g-recaptcha-response"); + if (element != null) + document.getElementById("g-recaptcha-response").innerHTML = solution; + }, solution) + this.clickValid(); + } + } catch (e) { + log(e) + this.isTerminated = true; } - } catch (e) { - log(e) + } else { this.isTerminated = true; } - } else { - this.isTerminated = true; - } - }) + }) + } else { + await this.clickValid(); + } } async isBlocked() { From b0064268678666b93161abd87356a0c150681f15 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Mon, 6 Mar 2023 20:13:00 +0100 Subject: [PATCH 02/16] check recaptcha before calling 2captcha --- src/workers/CommandorPage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 0bdd8ad..e024bd9 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -7,7 +7,7 @@ const { shell } = require('electron') const GeoCaptchaSolver = require("./GeoCaptchaSolver"); -// const RDV_URL = "http://192.168.0.13:8000/test_appointment.html" +// const RDV_URL = "http://192.168.0.13: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"; @@ -313,7 +313,8 @@ class CommandorPage { return } //check whether there is captcha - let hasCaptcha = await page.isVisible("g-recaptcha-response") + let pageContent = await page.content() + let hasCaptcha = pageContent.includes("g-recaptcha-response") if (hasCaptcha) { this.captchaSolver = new SolveCaptcha(page); await this.captchaSolver.start((solution) => { From a10413f4d22f4e476a67d175986d326d743f5833 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Thu, 9 Mar 2023 09:10:36 +0100 Subject: [PATCH 03/16] add emulator --- clear_data.bat | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clear_data.bat b/clear_data.bat index f4d1012..602b399 100644 --- a/clear_data.bat +++ b/clear_data.bat @@ -245,4 +245,9 @@ adb -s 4b99c21 shell am start -n com.android.chrome/com.google.android.apps.chro #huawei mate 8 adb -s APU7N16321020182 shell pm clear com.android.chrome adb -s APU7N16321020182 shell am set-debug-app --persistent com.android.chrome -adb -s APU7N16321020182 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s APU7N16321020182 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#huawei mate 8 +adb -s emulator-5554 shell pm clear com.android.chrome +adb -s emulator-5554 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5554 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file From 442368bd11eb8fc75d4bdfc121f813b68812f464 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Mon, 13 Mar 2023 00:17:47 +0100 Subject: [PATCH 04/16] add more devices --- clear_data.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/clear_data.sh b/clear_data.sh index 744840f..30da4ba 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -294,4 +294,29 @@ adb -s 192.168.0.27:5555 shell am start -n com.android.chrome/com.google.android #18 adb -s emulator-5560 shell pm clear com.android.chrome adb -s emulator-5560 shell am set-debug-app --persistent com.android.chrome -adb -s emulator-5560 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s emulator-5560 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s emulator-5564 shell pm clear com.android.chrome +adb -s emulator-5564 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5564 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s emulator-5566 shell pm clear com.android.chrome +adb -s emulator-5566 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5566 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s emulator-5568 shell pm clear com.android.chrome +adb -s emulator-5568 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5568 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s emulator-5570 shell pm clear com.android.chrome +adb -s emulator-5570 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5570 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s emulator-5572 shell pm clear com.android.chrome +adb -s emulator-5572 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5572 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file From 9197600bd2c3cab075fcaeb0353a752d46b886f8 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Tue, 14 Mar 2023 23:08:31 +0100 Subject: [PATCH 05/16] use oppo to validate emails --- clear_data.sh | 16 ++++------------ src/appointment.js | 2 +- start_avds.sh | 4 ++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/clear_data.sh b/clear_data.sh index 744840f..51a89b4 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -4,19 +4,16 @@ adb -s RQ3005CA88 shell am start -n com.android.chrome/com.google.android.apps.c adb -s J4AXB761H2322WJ shell pm clear com.android.chrome adb -s J4AXB761H2322WJ shell am set-debug-app --persistent com.android.chrome adb -s J4AXB761H2322WJ shell am start -n com.android.chrome/com.google.android.apps.chrome.Main -adb -s e30eb015 shell pm clear com.android.chrome -adb -s e30eb015 shell am set-debug-app --persistent com.android.chrome -adb -s e30eb015 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main adb -s 07f9c883 shell pm clear com.android.chrome adb -s 07f9c883 shell am set-debug-app --persistent com.android.chrome adb -s 07f9c883 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main adb -s 76a3ac8d shell pm clear com.android.chrome adb -s 76a3ac8d shell am set-debug-app --persistent com.android.chrome adb -s 76a3ac8d shell am start -n com.android.chrome/com.google.android.apps.chrome.Main -#xiao mi -adb -s 47e7e36b shell pm clear com.android.chrome -adb -s 47e7e36b shell am set-debug-app --persistent com.android.chrome -adb -s 47e7e36b shell am start -n com.android.chrome/com.google.android.apps.chrome.Main +#coo +adb -s feb04f82 shell pm clear com.android.chrome +adb -s feb04f82 shell am set-debug-app --persistent com.android.chrome +adb -s feb04f82 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main #huawei adb -s EPHUT20825001518 shell pm clear com.android.chrome adb -s EPHUT20825001518 shell am set-debug-app --persistent com.android.chrome @@ -59,11 +56,6 @@ adb -s 6c3076e6 shell pm clear com.android.chrome adb -s 6c3076e6 shell am set-debug-app --persistent com.android.chrome adb -s 6c3076e6 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main -#samsung J5 - 2016 -adb -s 774687ff shell pm clear com.android.chrome -adb -s 774687ff shell am set-debug-app --persistent com.android.chrome -adb -s 774687ff shell am start -n com.android.chrome/com.google.android.apps.chrome.Main - #samsung J5 - 2016 adb -s ffa9b2bc shell pm clear com.android.chrome adb -s ffa9b2bc shell am set-debug-app --persistent com.android.chrome diff --git a/src/appointment.js b/src/appointment.js index dbd69d1..c6cc184 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -10,7 +10,7 @@ const SEVEN_DAYS_IN_S = 3600 * 24 * 7; const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3; let excelUtil = new ExcelUtil(); let collectionName = formatDate(new Date()) -device_to_excludes = ["47e7e36b", "e30eb015"] +device_to_excludes = ["47e7e36b", "e30eb015","774687ff"] async function filterAlreadyBookedContacts(contactList) { let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName); diff --git a/start_avds.sh b/start_avds.sh index 5a927e8..162d52d 100644 --- a/start_avds.sh +++ b/start_avds.sh @@ -8,5 +8,5 @@ emulator -avd Pixel_2_API_30_6 & emulator -avd Pixel_2_API_30_7 & emulator -avd Pixel_2_API_30_8 & emulator -avd Pixel_2_API_30_9 & -emulator -avd Pixel_2_API_30_10 & -emulator -avd Pixel_2_API_30_11 & \ No newline at end of file +#emulator -avd Pixel_2_API_30_10 & +#emulator -avd Pixel_2_API_30_11 & \ No newline at end of file From ada9f4a07c06b722755e1c7bf9b04997f00aea3e Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Thu, 16 Mar 2023 21:43:17 +0100 Subject: [PATCH 06/16] make search term more extact --- src/workers/CommandorPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index e024bd9..dfcaafb 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -36,7 +36,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+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment'] function delay(delayInMs) { return new Promise(resolve => { From 25475480f0c90e756167eca110d9cf7cfdb3be38 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Fri, 17 Mar 2023 13:42:55 +0100 Subject: [PATCH 07/16] update to playwright 1.31.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea750ec..1507de6 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "node-schedule": "^2.1.0", "node-wget": "^0.4.3", "node-xlsx": "^0.21.0", - "playwright": "1.23.0", + "playwright": "1.31.2", "read-ini-file": "^3.0.1", "winston": "^3.8.2", "yarn": "^1.22.19" From 506b05d5f51a2419b3e4f6a7bf3bad151c62e4fd Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Fri, 17 Mar 2023 13:50:01 +0100 Subject: [PATCH 08/16] update to playwright 1.25.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1507de6..6f2f350 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "node-schedule": "^2.1.0", "node-wget": "^0.4.3", "node-xlsx": "^0.21.0", - "playwright": "1.31.2", + "playwright": "1.25.2", "read-ini-file": "^3.0.1", "winston": "^3.8.2", "yarn": "^1.22.19" From c036311afa2850ca5e90f9efed09a435df238d0d Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 18 Mar 2023 11:46:14 +0100 Subject: [PATCH 09/16] use rendezvousparis instead of online appointment --- src/workers/CommandorPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index dfcaafb..99595e3 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -114,7 +114,7 @@ class CommandorPage { // log(e) // } try { - this.page.locator(':nth-match(:text("Online Appointment"), 1)').click() + this.page.locator(':nth-match(:text("rendezvousparis"), 1)').click() } catch (e) { log(e) this.isTerminated = true From 3361db1cc2c8550f8be04a6b972e46f012919a3a Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Fri, 31 Mar 2023 20:01:03 +0200 Subject: [PATCH 10/16] click on the checkbox --- package.json | 2 +- src/workers/CommandorPage.js | 57 +++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 6f2f350..99cbabc 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "node-schedule": "^2.1.0", "node-wget": "^0.4.3", "node-xlsx": "^0.21.0", - "playwright": "1.25.2", + "playwright": "^1.32.1", "read-ini-file": "^3.0.1", "winston": "^3.8.2", "yarn": "^1.22.19" diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 99595e3..04bfa4d 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -81,18 +81,23 @@ class CommandorPage { // Connect to the device. log("loadPage() called"); // await this.device.shell('am force-stop com.android.chrome'); - const context = await this.device.launchBrowser(); - // await context.clearCookies() + try { + this.context = await this.device.launchBrowser(); + // await context.clearCookies() + // Use BrowserContext as usual. + this.page = await this.context.newPage(); + this.page.on("load", (loadedPage) => { + this.onPageLoad(loadedPage) + }) - // Use BrowserContext as usual. - this.page = await context.newPage(); - this.page.on("load", (loadedPage) => { - this.onPageLoad(loadedPage) - }) + this.page.on("response", (response) => { + this.onResponse(response) + }) + } catch (e) { + log(e) + this.isTerminated = true + } - this.page.on("response", (response) => { - this.onResponse(response) - }) 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}); @@ -104,15 +109,9 @@ class CommandorPage { try { if (this.page.url().includes("google")) this.page.locator('button >> nth=3').click() - // this.page.locator('button:has-text("Tout accepter")').click() } catch (e) { log(e) } - // try { - // this.page.locator('button:has-text("Accept all")').click() - // } catch (e) { - // log(e) - // } try { this.page.locator(':nth-match(:text("rendezvousparis"), 1)').click() } catch (e) { @@ -124,12 +123,17 @@ class CommandorPage { const intervalTask = setInterval(() => { if (this.isTerminated) { log(this.device.model() + ":request terminated, will close device"); - context.close(); + this.context.close(); // this.page.close() - this.device.close() + // this.device.close() clearInterval(intervalTask) cancel() - return context + return this.context + } else { + if (this.page.url() === RDV_URL) { + if (!this.isFillingFields) + this.fillFields(this.page); + } } }, 10 * 1000)//interval of 10 seconds @@ -316,6 +320,8 @@ class CommandorPage { let pageContent = await page.content() let hasCaptcha = pageContent.includes("g-recaptcha-response") if (hasCaptcha) { + await this.clickCheckbox() + await delay(1000) this.captchaSolver = new SolveCaptcha(page); await this.captchaSolver.start((solution) => { log("solution is: " + solution); @@ -370,8 +376,8 @@ class CommandorPage { } else { if (currentPage.url() === RDV_URL) { await this.fillFields(this.page); - if (this.isFillingFields) - await this.getErrors() + // if (this.isFillingFields) + // await this.getErrors() } else { if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) { log("successful"); @@ -462,6 +468,15 @@ class CommandorPage { } } + async clickCheckbox() { + try { + // let errorItem = await this.page.click("#recaptcha-anchor > div.recaptcha-checkbox-border") + await this.page.frameLocator('[title="reCAPTCHA"]').getByRole('checkbox', {name: 'I\'m not a robot'}).click(); + } catch (e) { + log(e); + } + } + async handleError(errorContent) { log("handle error:" + errorContent); if (errorContent.includes(DOUBLE_REQUEST_ERROR_MESSAGE) || errorContent.includes(DOUBLE_REQUEST_ERROR_MESSAGE_FR)) { From d1970470c9d9c8635ced3b33e85ac4840f0779a5 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 1 Apr 2023 11:27:20 +0200 Subject: [PATCH 11/16] inverse firstName and lastName --- src/workers/CommandorPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 04bfa4d..4ef1a4c 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -201,10 +201,10 @@ class CommandorPage { if (!this.isNameInput) { await page.locator(LAST_NAME).focus() await delay(getRandomWaitTime()) - await page.locator(LAST_NAME).fill(this.contact.lastName) + await page.locator(LAST_NAME).fill(this.contact.firstName) await page.locator(FIRST_NAME).focus() await delay(getRandomWaitTime()) - await page.locator(FIRST_NAME).fill(this.contact.firstName) + await page.locator(FIRST_NAME).fill(this.contact.lastName) this.isNameInput = true } } From 4487b5cf503f80c32cf0b8930270f92b34e13e5c Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 1 Apr 2023 11:36:29 +0200 Subject: [PATCH 12/16] add +33 to phone number --- src/workers/CommandorPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 4ef1a4c..d5b303b 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -184,7 +184,7 @@ class CommandorPage { if (!page.isClosed()) { if (!this.isPhoneInput) { await page.locator(PHONE_NUMBER).focus(); - await page.locator(PHONE_NUMBER).fill("0" + this.contact.phoneNumber); + await page.locator(PHONE_NUMBER).fill("+33" + this.contact.phoneNumber); this.isPhoneInput = true; } } From ec29772cae066de3c45a14d2d5d44fc68e135360 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 1 Apr 2023 19:15:19 +0200 Subject: [PATCH 13/16] reverse lastName and firstName --- src/workers/CommandorPage.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index d5b303b..3547d7f 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -123,7 +123,8 @@ class CommandorPage { const intervalTask = setInterval(() => { if (this.isTerminated) { log(this.device.model() + ":request terminated, will close device"); - this.context.close(); + if (this.context !== undefined) + this.context.close(); // this.page.close() // this.device.close() clearInterval(intervalTask) @@ -201,10 +202,10 @@ class CommandorPage { if (!this.isNameInput) { await page.locator(LAST_NAME).focus() await delay(getRandomWaitTime()) - await page.locator(LAST_NAME).fill(this.contact.firstName) + await page.locator(LAST_NAME).fill(this.contact.lastName) await page.locator(FIRST_NAME).focus() await delay(getRandomWaitTime()) - await page.locator(FIRST_NAME).fill(this.contact.lastName) + await page.locator(FIRST_NAME).fill(this.contact.firstName) this.isNameInput = true } } From 04a3acb5e986523a02823356e66ec5ba8b90f820 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 4 Apr 2023 10:30:16 +0200 Subject: [PATCH 14/16] try to save cookies --- src/workers/CommandorPage.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 3547d7f..14a0d36 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -382,6 +382,13 @@ class CommandorPage { } else { if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) { log("successful"); + // save cookies + try { + let cookies = await this.context.cookies() + await fs.writeFileSync(this.contact.mail + '.txt', cookies.join('\n')); + } catch (e) { + console.log(e) + } await this.push_message_to_queue(PublishType.SUCCESS); } else if (content.includes(EMPTY_RESPONSE_ERROR)) { log("EMPTY_RESPONSE_ERROR error received, will quit") From 3539ddb3f1fb6fbfe2fe5a9ef463cfdb90803468 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 4 Apr 2023 11:10:03 +0200 Subject: [PATCH 15/16] correction of writing cookies --- src/workers/CommandorPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 14a0d36..f1d7bed 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -385,7 +385,7 @@ class CommandorPage { // save cookies try { let cookies = await this.context.cookies() - await fs.writeFileSync(this.contact.mail + '.txt', cookies.join('\n')); + await require("fs").writeFileSync(this.contact.mail + '.txt', cookies.join('\n')); } catch (e) { console.log(e) } From 81c9b6823e6f090e3202539fee60627cc1417ac5 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 4 Apr 2023 11:17:31 +0200 Subject: [PATCH 16/16] correction of writing cookies --- src/workers/CommandorPage.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index f1d7bed..330b19a 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -384,8 +384,13 @@ class CommandorPage { log("successful"); // save cookies try { - let cookies = await this.context.cookies() - await require("fs").writeFileSync(this.contact.mail + '.txt', cookies.join('\n')); + + let cookies = await this.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) }