Merge branch 'feature/share_cookies' of bitbucket.org:panleicim/puppeteerjs into feature/share_cookies

This commit is contained in:
Lei PAN
2024-02-17 12:06:51 +01:00
4 changed files with 32 additions and 24 deletions
+5 -1
View File
@@ -19,7 +19,11 @@ class ExcelUtil {
if (store === undefined || store.length === 0) { if (store === undefined || store.length === 0) {
store = "random" store = "random"
} }
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store); let ipCountry = info[5];
if (ipCountry === undefined || ipCountry.length === 0) {
ipCountry = "FR"
}
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry);
contactList.push(newContact); contactList.push(newContact);
} }
} }
+2 -3
View File
@@ -1,15 +1,14 @@
class ContactPojo { class ContactPojo {
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store) { constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry) {
this.phoneNumber = phoneNumber; this.phoneNumber = phoneNumber;
this.passportNumber = passportNumber; this.passportNumber = passportNumber;
this.lastName = lastName; this.lastName = lastName;
this.firstName = firstName; this.firstName = firstName;
this.mail = mail; this.mail = mail;
this.store = store; this.store = store;
this.ipCountry = ipCountry;
} }
} }
module.exports = ContactPojo module.exports = ContactPojo
+5 -4
View File
@@ -1,7 +1,8 @@
const amqp = require("amqplib"); const amqp = require("amqplib");
const QUEUE_HOST = "amqp://appointment:ZyuhJZ2xEYWhElhpJjy7YEpZGZwNYJz2fHIu@appointment.lpaconsulting.fr:5672" const QUEUE_HOST = "amqp://appointment:ZyuhJZ2xEYWhElhpJjy7YEpZGZwNYJz2fHIu@appointment.lpaconsulting.fr:5672"
const REQUEST_DATA_QUEUE = 'REQUEST_DATA'; const REQUEST_DATA_QUEUE_FR = 'REQUEST_DATA';
const REQUEST_DATA_QUEUE_DE = 'REQUEST_DATA_DE';
class Sender { class Sender {
channel; channel;
@@ -10,11 +11,11 @@ class Sender {
async initConnection() { async initConnection() {
this.connection = await amqp.connect(QUEUE_HOST); this.connection = await amqp.connect(QUEUE_HOST);
this.channel = await this.connection.createChannel(); this.channel = await this.connection.createChannel();
await this.channel.assertQueue(REQUEST_DATA_QUEUE, {persistent: true}); await this.channel.assertQueue(REQUEST_DATA_QUEUE_FR, {persistent: true});
} }
sendMessage(msg) { sendMessage(msg, queue_name = REQUEST_DATA_QUEUE_FR) {
this.channel.sendToQueue(REQUEST_DATA_QUEUE, Buffer.from(msg)) this.channel.sendToQueue(queue_name, Buffer.from(msg))
} }
} }
+18 -14
View File
@@ -891,6 +891,10 @@ class CommandorPage {
cookiesString = cookiesString + cookie.name + "=" + cookie.value + ";" cookiesString = cookiesString + cookie.name + "=" + cookie.value + ";"
}) })
console.log(cookiesString); console.log(cookiesString);
if (this.contact.ipCountry === "DE")
this.sender.sendMessage(cookiesString, "REQUEST_DATA_DE")
else
this.sender.sendMessage(cookiesString) this.sender.sendMessage(cookiesString)
// let content = await this.page.content() // let content = await this.page.content()
// console.log(content) // console.log(content)
@@ -1228,21 +1232,21 @@ class CommandorPage {
async enableDisableAirPlanMode() { async enableDisableAirPlanMode() {
logWithDevice("will enable/disable airplane mode", this.device) logWithDevice("will enable/disable airplane mode", this.device)
try { // try {
// await this.device.shell("cmd connectivity airplane-mode enable") // // await this.device.shell("cmd connectivity airplane-mode enable")
await exceutShellCmd(this.device, "cmd connectivity airplane-mode enable") // await exceutShellCmd(this.device, "cmd connectivity airplane-mode enable")
await delay(1000) // await delay(1000)
await exceutShellCmd(this.device, "cmd connectivity airplane-mode disable") // await exceutShellCmd(this.device, "cmd connectivity airplane-mode disable")
// // await this.device.shell("cmd connectivity airplane-mode disable")
// await delay(2000)
// } catch (e) {
// try {
// await this.device.shell("cmd connectivity airplane-mode disable") // await this.device.shell("cmd connectivity airplane-mode disable")
await delay(2000) // } catch (e) {
} catch (e) { // console.log(e)
try { // }
await this.device.shell("cmd connectivity airplane-mode disable") // console.log(e)
} catch (e) { // }
console.log(e)
}
console.log(e)
}
} }
async tapGoogleDisconnectBtn() { async tapGoogleDisconnectBtn() {