Merge branch 'master' of bitbucket.org:panleicim/appointment_tool_js
This commit is contained in:
+14
-4
@@ -10,20 +10,30 @@ adb -s 07f9c883 shell am start -n com.android.chrome/com.google.android.apps.chr
|
|||||||
adb -s 76a3ac8d shell pm clear com.android.chrome
|
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 set-debug-app --persistent com.android.chrome
|
||||||
adb -s 76a3ac8d shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
adb -s 76a3ac8d 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
|
#huawei
|
||||||
adb -s EPHUT20825001518 shell pm clear com.android.chrome
|
adb -s EPHUT20825001518 shell pm clear com.android.chrome
|
||||||
adb -s EPHUT20825001518 shell am set-debug-app --persistent com.android.chrome
|
adb -s EPHUT20825001518 shell am set-debug-app --persistent com.android.chrome
|
||||||
adb -s EPHUT20825001518 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
adb -s EPHUT20825001518 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|
||||||
|
#huawei
|
||||||
|
adb -s 4e8ca027 shell pm clear com.android.chrome
|
||||||
|
adb -s 4e8ca027 shell am set-debug-app --persistent com.android.chrome
|
||||||
|
adb -s 4e8ca027 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|
||||||
#xiaomi tab
|
#xiaomi tab
|
||||||
adb -s 5ac879a2 shell pm clear com.android.chrome
|
adb -s 5ac879a2 shell pm clear com.android.chrome
|
||||||
adb -s 5ac879a2 shell am set-debug-app --persistent com.android.chrome
|
adb -s 5ac879a2 shell am set-debug-app --persistent com.android.chrome
|
||||||
adb -s 5ac879a2 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
adb -s 5ac879a2 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|
||||||
|
#oppo tab
|
||||||
|
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
|
||||||
|
|
||||||
|
#oneplus 6 tab
|
||||||
|
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
|
||||||
#xiaomi tab
|
#xiaomi tab
|
||||||
adb -s 835dca3e shell pm clear com.android.chrome
|
adb -s 835dca3e shell pm clear com.android.chrome
|
||||||
adb -s 835dca3e shell am set-debug-app --persistent com.android.chrome
|
adb -s 835dca3e shell am set-debug-app --persistent com.android.chrome
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
"node-xlsx": "^0.21.0",
|
"node-xlsx": "^0.21.0",
|
||||||
"playwright": "^1.32.1",
|
"playwright": "^1.32.1",
|
||||||
"read-ini-file": "^3.0.1",
|
"read-ini-file": "^3.0.1",
|
||||||
|
"uuid": "^9.0.0",
|
||||||
|
"image-size": "^1.0.2",
|
||||||
"winston": "^3.8.2",
|
"winston": "^3.8.2",
|
||||||
"yarn": "^1.22.19"
|
"yarn": "^1.22.19"
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-1
@@ -10,7 +10,8 @@ const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
|
|||||||
const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
|
const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
|
||||||
let excelUtil = new ExcelUtil();
|
let excelUtil = new ExcelUtil();
|
||||||
let collectionName = formatDate(new Date())
|
let collectionName = formatDate(new Date())
|
||||||
device_to_excludes = ["47e7e36b", "e30eb015","774687ff"]
|
// device_to_excludes = ["47e7e36b", "e30eb015"]
|
||||||
|
device_to_excludes = ["47e7e36b"]
|
||||||
|
|
||||||
async function filterAlreadyBookedContacts(contactList) {
|
async function filterAlreadyBookedContacts(contactList) {
|
||||||
let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
@@ -124,6 +125,7 @@ async function startBook(contactPojo, device, selectedStore, audioAnalyse, alert
|
|||||||
|
|
||||||
async function startWithList(contacts, device, selectedStore, audioAnalyse, alertBeep) {
|
async function startWithList(contacts, device, selectedStore, audioAnalyse, alertBeep) {
|
||||||
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
|
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
|
||||||
|
// let duplicatedList = [].concat(contacts)
|
||||||
await duplicatedList.reduce(async (promise, contactPojo) => {
|
await duplicatedList.reduce(async (promise, contactPojo) => {
|
||||||
// This line will wait for the last async function to finish.
|
// This line will wait for the last async function to finish.
|
||||||
// The first iteration uses an already resolved Promise
|
// The first iteration uses an already resolved Promise
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ class ExcelUtil {
|
|||||||
(info, index, list) => {
|
(info, index, list) => {
|
||||||
if (index > 0 && info.length > 0) {
|
if (index > 0 && info.length > 0) {
|
||||||
// console.log(info)
|
// console.log(info)
|
||||||
let name = info[0].split(" ")
|
if (info[0].includes("Aijing")){
|
||||||
|
console.log("found");
|
||||||
|
}
|
||||||
|
let name = info[0].trim().split(" ")
|
||||||
let firstName = name[1];
|
let firstName = name[1];
|
||||||
let lastName = name[0];
|
let lastName = name[0];
|
||||||
let phoneNumber = info[1];
|
let phoneNumber = info[1];
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class Position {
|
||||||
|
constructor(x, y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = Position
|
||||||
+113
-32
@@ -7,7 +7,8 @@ const {
|
|||||||
shell
|
shell
|
||||||
} = require('electron')
|
} = require('electron')
|
||||||
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
||||||
// const RDV_URL = "http://192.168.0.13:8000/test_appointment.html";
|
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 RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||||
const BLANK_URL = "about:blank"
|
const BLANK_URL = "about:blank"
|
||||||
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
||||||
@@ -36,6 +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 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 REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
||||||
const DEFAULT_STORE = 'faubourg';
|
const DEFAULT_STORE = 'faubourg';
|
||||||
|
|
||||||
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']
|
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) {
|
function delay(delayInMs) {
|
||||||
@@ -58,6 +60,10 @@ function log(message) {
|
|||||||
appointmentLogger.log({level: "info", message: message})
|
appointmentLogger.log({level: "info", message: message})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logWithDevice(message, device) {
|
||||||
|
appointmentLogger.log({level: "info", message: device.model() + ":" + message})
|
||||||
|
}
|
||||||
|
|
||||||
class CommandorPage {
|
class CommandorPage {
|
||||||
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false) {
|
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false) {
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
@@ -101,7 +107,6 @@ class CommandorPage {
|
|||||||
try {
|
try {
|
||||||
const item = searchTexts[Math.floor(Math.random() * searchTexts.length)];
|
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("https://www.google.com/search?q=" + item + "&lr=lang_en", {timeout: 90 * 1000});
|
||||||
// await this.page.goto(RDV_URL, {timeout: 90 * 1000});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e)
|
log(e)
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
@@ -113,10 +118,13 @@ class CommandorPage {
|
|||||||
log(e)
|
log(e)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
// await this.setUpCookies()
|
||||||
this.page.locator(':nth-match(:text("rendezvousparis"), 1)').click()
|
this.page.locator(':nth-match(:text("rendezvousparis"), 1)').click()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e)
|
log(e)
|
||||||
this.isTerminated = true
|
if (!this.page.url().includes(RDV_URL)) {
|
||||||
|
this.isTerminated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let cancel
|
let cancel
|
||||||
@@ -185,7 +193,7 @@ class CommandorPage {
|
|||||||
if (!page.isClosed()) {
|
if (!page.isClosed()) {
|
||||||
if (!this.isPhoneInput) {
|
if (!this.isPhoneInput) {
|
||||||
await page.locator(PHONE_NUMBER).focus();
|
await page.locator(PHONE_NUMBER).focus();
|
||||||
await page.locator(PHONE_NUMBER).fill("+33" + this.contact.phoneNumber);
|
await page.locator(PHONE_NUMBER).fill("+330" + this.contact.phoneNumber);
|
||||||
this.isPhoneInput = true;
|
this.isPhoneInput = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,6 +296,7 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async clickValid(page) {
|
async clickValid(page) {
|
||||||
|
await this.saveCookies()
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime())
|
||||||
try {
|
try {
|
||||||
if (!this.page.isClosed()) {
|
if (!this.page.isClosed()) {
|
||||||
@@ -357,7 +366,7 @@ class CommandorPage {
|
|||||||
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("audio_tag: " + html);
|
||||||
return html.includes("You have been blocked")
|
return html.includes("You have been blocked") || html.includes("Vous avez été bloqué")
|
||||||
}
|
}
|
||||||
|
|
||||||
async onPageLoad(currentPage) {
|
async onPageLoad(currentPage) {
|
||||||
@@ -374,29 +383,42 @@ class CommandorPage {
|
|||||||
shell.beep()
|
shell.beep()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log("发现datadome");
|
logWithDevice("发现datadome", this.device);
|
||||||
|
} else if (content.includes("502 Bad Gateway")) {
|
||||||
|
logWithDevice("502 Bad Gateway found", this.device)
|
||||||
|
await this.page.reload()
|
||||||
} else if (currentPage.url().includes("sorry")) {
|
} else if (currentPage.url().includes("sorry")) {
|
||||||
await this.resetBrowser()
|
await this.resetBrowser()
|
||||||
|
} else if (content.includes("PROXY_CONNECTION_FAILED")) {
|
||||||
|
logWithDevice("PROXY_CONNECTION_FAILED, will reload page", this.device);
|
||||||
|
await delay(2000)
|
||||||
|
await this.page.reload()
|
||||||
|
} else if (content.includes("ERR_NETWORK_CHANGED")) {
|
||||||
|
logWithDevice("ERR_NETWORK_CHANGED, will reload page", this.device);
|
||||||
|
await delay(2000)
|
||||||
|
await this.page.reload()
|
||||||
|
} else if (content.includes("CACHE_MISS")) {
|
||||||
|
logWithDevice("CACHE_MISS, will reload page", this.device);
|
||||||
|
await delay(2000)
|
||||||
|
// await this.setUpCookies()
|
||||||
|
await this.page.reload()
|
||||||
|
} else if (content.includes("ERR_TIMED_OUT")) {
|
||||||
|
logWithDevice("ERR_TIMED_OUT, will reload page", this.device);
|
||||||
|
await delay(2000)
|
||||||
|
await this.page.reload()
|
||||||
|
} else if (content.includes("408 Request Time-out")) {
|
||||||
|
logWithDevice("Request Time-out, will reload page", this.device);
|
||||||
|
await delay(2000)
|
||||||
|
await this.page.reload()
|
||||||
} else {
|
} else {
|
||||||
if (currentPage.url() === RDV_URL) {
|
if (currentPage.url() === RDV_URL) {
|
||||||
await this.fillFields(this.page);
|
await this.fillFields(this.page);
|
||||||
|
await this.saveCookies()
|
||||||
// if (this.isFillingFields)
|
// if (this.isFillingFields)
|
||||||
// await this.getErrors()
|
// await this.getErrors()
|
||||||
} else {
|
} else {
|
||||||
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
|
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
|
||||||
log("successful");
|
log("successful");
|
||||||
// save cookies
|
|
||||||
try {
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
await this.push_message_to_queue(PublishType.SUCCESS);
|
await this.push_message_to_queue(PublishType.SUCCESS);
|
||||||
} else if (content.includes(EMPTY_RESPONSE_ERROR)) {
|
} else if (content.includes(EMPTY_RESPONSE_ERROR)) {
|
||||||
log("EMPTY_RESPONSE_ERROR error received, will quit")
|
log("EMPTY_RESPONSE_ERROR error received, will quit")
|
||||||
@@ -412,45 +434,102 @@ 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async checkAudioBtn() {
|
async checkAudioBtn() {
|
||||||
let isBlocked = await this.isBlocked()
|
let isBlocked = await this.isBlocked()
|
||||||
if (!isBlocked) {
|
if (!isBlocked) {
|
||||||
let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button");
|
//try to sliding capthca at first
|
||||||
log("audioBtn found")
|
let slidingCaptchaSolver = new SlidingCaptchaSolver(this.device);
|
||||||
audioBtn.click()
|
await slidingCaptchaSolver.solve(this.page, async (isSuccessful) => {
|
||||||
let captchaSolver = new GeoCaptchaSolver(this.page, this.device, this.isTerminated)
|
console.log("check isAlwaysBlocked")
|
||||||
await captchaSolver.solve((isSuccessful) => {
|
let isAlwaysBlocked = await this.isBlocked();
|
||||||
if (!isSuccessful) {
|
if (isAlwaysBlocked) {
|
||||||
this.isTerminated = true
|
await this.resolveByAudio();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async onResponse(response) {
|
async onResponse(response) {
|
||||||
// let rex = new RegExp(REGEX_RDV_URL)
|
let rex = new RegExp(REGEX_RDV_URL)
|
||||||
// log("onResponse with url:" + response.url())
|
log("onResponse with url:" + response.url())
|
||||||
// if (rex.test(response.url())) {
|
// log("onResponse with url:" + response.body())
|
||||||
// log("rdv url found:" + response.url())
|
if (rex.test(response.url())) {
|
||||||
// await this.push_message_to_db(PublishType.SUCCESS, response.url())
|
log("rdv url found:" + response.url())
|
||||||
|
// save cookies
|
||||||
|
await this.saveCookies();
|
||||||
|
await this.push_message_to_db(PublishType.SUCCESS, response.url())
|
||||||
|
}
|
||||||
|
// if (response.url().includes("geo.captcha-delivery.com/interstitial")) {
|
||||||
|
// logWithDevice("interstitial: response.status is " + response.status())
|
||||||
|
// await this.setUpCookies()
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
async push_message_to_queue(publishType) {
|
async push_message_to_queue(publishType) {
|
||||||
let url = this.page.url();
|
let url = this.page.url();
|
||||||
|
await this.push_message_to_db(publishType, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
async push_message_to_db(publishType, url) {
|
||||||
let splitedUrl = url.split("/");
|
let splitedUrl = url.split("/");
|
||||||
let id = splitedUrl[splitedUrl.length - 1];
|
let id = splitedUrl[splitedUrl.length - 1];
|
||||||
if (url === "https://rendezvousparis.hermes.com/client/welcome") {
|
if (url === "https://rendezvousparis.hermes.com/client/welcome") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// save to mongoDb
|
// save to mongoDb
|
||||||
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, this.page.url(), this.choosedStore, publishType);
|
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType);
|
||||||
reserve.source_from = this.device.model();
|
reserve.source_from = this.device.model();
|
||||||
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
||||||
await this.deleteFromBlackList()
|
await this.deleteFromBlackList()
|
||||||
@@ -523,6 +602,8 @@ class CommandorPage {
|
|||||||
await delay(1000)
|
await delay(1000)
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = CommandorPage
|
module.exports = CommandorPage
|
||||||
@@ -60,7 +60,7 @@ async function sendRequest(fileName, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GeoCaptchaSolver {
|
class AudioCaptchaSolver {
|
||||||
constructor(page, device, isTerminated) {
|
constructor(page, device, isTerminated) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.isTerminated = isTerminated
|
this.isTerminated = isTerminated
|
||||||
@@ -170,4 +170,4 @@ class GeoCaptchaSolver {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = GeoCaptchaSolver
|
module.exports = AudioCaptchaSolver
|
||||||
|
|||||||
@@ -0,0 +1,128 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const {exec} = require("child_process");
|
||||||
|
|
||||||
|
const {promisify} = require('util')
|
||||||
|
const Position = require("../models/Position");
|
||||||
|
|
||||||
|
const sizeOf = promisify(require('image-size'));
|
||||||
|
|
||||||
|
const axios = require("axios");
|
||||||
|
const {v4: uuidv4} = require('uuid');
|
||||||
|
|
||||||
|
const DEEPLEARNING_CAPTCHA_HOST = "http://appointment.lpaconsulting.fr:9000"
|
||||||
|
|
||||||
|
function delay(delayInMs) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(2);
|
||||||
|
}, delayInMs);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomIntFromInterval(min, max) { // min and max included
|
||||||
|
return Math.floor(Math.random() * (max - min + 1) + min)
|
||||||
|
}
|
||||||
|
|
||||||
|
const positionInfo = new Map();
|
||||||
|
|
||||||
|
positionInfo.set("2109119DG", new Position(211, 1710))
|
||||||
|
positionInfo.set("ONEPLUS A6000", new Position(211, 1706))
|
||||||
|
positionInfo.set("SM-C5000", new Position(180, 1794))
|
||||||
|
|
||||||
|
class SlidingCaptchaSolver {
|
||||||
|
constructor(device) {
|
||||||
|
this.device = device;
|
||||||
|
}
|
||||||
|
|
||||||
|
async solve(page, onResult) {
|
||||||
|
await this.sliding_captcha(this.device, onResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
async take_screen_shot(name, device) {
|
||||||
|
// let stdout1 = await exec("adb -s " + device.serial() + " shell screencap -p /sdcard/" + name)
|
||||||
|
console.log("take screenshot " + name);
|
||||||
|
await device.screenshot({path: name});
|
||||||
|
// let stdout1 = await exec("adb -s " + device.serial() + " exec-out screencap -p > " + name)
|
||||||
|
await delay(1000);
|
||||||
|
// console.log(`stdout: ${stdout1}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async sliding_captcha(device, onResult) {
|
||||||
|
// take screenshot
|
||||||
|
console.log("take screenshot")
|
||||||
|
let blockedFileName = uuidv4();
|
||||||
|
let blockedImageFileName = "blocked_" + blockedFileName + ".png"
|
||||||
|
await this.take_screen_shot(blockedImageFileName, device)
|
||||||
|
//get resolution of screen
|
||||||
|
await this.sendRequest(blockedImageFileName, async (detectedPositionList) => {
|
||||||
|
console.log("detectedPosition is " + detectedPositionList);
|
||||||
|
if (detectedPositionList.length === 2) {
|
||||||
|
// #xiaomi
|
||||||
|
let startPosition = detectedPositionList.filter((positionInfo) => {
|
||||||
|
return positionInfo.label === "origin"
|
||||||
|
})[0]
|
||||||
|
let targetPosition = detectedPositionList.filter((positionInfo) => {
|
||||||
|
return positionInfo.label === "target"
|
||||||
|
})[0]
|
||||||
|
if (startPosition !== undefined) {
|
||||||
|
let y0 = (startPosition.y2 + startPosition.y1) / 2.0;
|
||||||
|
let x0 = (startPosition.x2 + startPosition.x1) / 2.0;
|
||||||
|
let y1 = (targetPosition.y2 + targetPosition.y1) / 2.0;
|
||||||
|
let x1 = (targetPosition.x2 + targetPosition.x1) / 2.0;
|
||||||
|
let width = targetPosition.x2 - targetPosition.x1;
|
||||||
|
let randomTime = randomIntFromInterval(100, 500)
|
||||||
|
let cmd = `adb -s ${device.serial()} shell input swipe ${x0} ${y0} ${x1 + width * 0.5} ${y0} ${1000 + randomTime}`
|
||||||
|
await delay(2000);
|
||||||
|
console.log("cmd is " + cmd);
|
||||||
|
console.log("will slide captcha");
|
||||||
|
await exec(cmd);
|
||||||
|
await delay(5000);
|
||||||
|
onResult(true)
|
||||||
|
} else {
|
||||||
|
console.log("startPosition not found for " + device.model())
|
||||||
|
onResult(false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("startPosition not found for " + device.model())
|
||||||
|
onResult(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async sendRequest(fileName, callback) {
|
||||||
|
const fileStream = fs.createReadStream(fileName);
|
||||||
|
let response = await axios.post(DEEPLEARNING_CAPTCHA_HOST, fileStream, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'wav',
|
||||||
|
'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 === undefined) {
|
||||||
|
await callback({});
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (response.status === 200) {
|
||||||
|
let result = response.data;
|
||||||
|
console.log(result);
|
||||||
|
await callback(result);
|
||||||
|
// console.log("will delete png file: " + fileName);
|
||||||
|
// await fs.unlink(fileName, (err) => {
|
||||||
|
// if (err) throw err;
|
||||||
|
// console.log(fileName + ' was deleted');
|
||||||
|
// })
|
||||||
|
} else {
|
||||||
|
console.log("error");
|
||||||
|
await callback([]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = SlidingCaptchaSolver
|
||||||
+1
-2
@@ -1,4 +1,3 @@
|
|||||||
emulator -avd Pixel_2_API_30 &
|
|
||||||
emulator -avd Pixel_2_API_30_1 &
|
emulator -avd Pixel_2_API_30_1 &
|
||||||
emulator -avd Pixel_2_API_30_2 &
|
emulator -avd Pixel_2_API_30_2 &
|
||||||
emulator -avd Pixel_2_API_30_3 &
|
emulator -avd Pixel_2_API_30_3 &
|
||||||
@@ -8,5 +7,5 @@ emulator -avd Pixel_2_API_30_6 &
|
|||||||
emulator -avd Pixel_2_API_30_7 &
|
emulator -avd Pixel_2_API_30_7 &
|
||||||
emulator -avd Pixel_2_API_30_8 &
|
emulator -avd Pixel_2_API_30_8 &
|
||||||
emulator -avd Pixel_2_API_30_9 &
|
emulator -avd Pixel_2_API_30_9 &
|
||||||
#emulator -avd Pixel_2_API_30_10 &
|
emulator -avd Pixel_2_API_30_10 &
|
||||||
#emulator -avd Pixel_2_API_30_11 &
|
#emulator -avd Pixel_2_API_30_11 &
|
||||||
Reference in New Issue
Block a user