get raw data

This commit is contained in:
2023-07-10 18:09:57 +02:00
parent 5818ca302e
commit 58ef3c23f1
2 changed files with 50 additions and 2 deletions
+44 -2
View File
@@ -8,8 +8,7 @@ const puppeteer = require('puppeteer');
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
const SlidingCaptchaSolver = require("./SlidingCaptchaSolver");
const OCRChecker = require("./OCRChecker");
const {disconnect} = require("mongoose");
const {execSync} = require("child_process");
const {main} = 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 BLANK_URL = "about:blank"
@@ -381,6 +380,32 @@ class CommandorPage {
}
}
async getRawAppointmentInfo(page) {
let passportId = await page.evaluate(() => {
let field = document.getElementById("passport_id");
return field.value
})
let lastName = await page.evaluate(() => {
let field = document.getElementById("surname");
return field.value
})
let firstName = await page.evaluate(() => {
let field = document.getElementById("name");
return field.value
})
let phone = await page.evaluate(() => {
let field = document.getElementById("phone_number");
return field.value
})
let email = await page.evaluate(() => {
let field = document.getElementById("email");
return field.value
})
return new ReserveResultPojo(email, phone, passportId, email, lastName, firstName, "random", "", PublishType.PENDING)
}
async inputPassportId(page) {
logWithDevice("inputPassportId", this.device)
try {
@@ -659,6 +684,23 @@ class CommandorPage {
return
}
// save to mongoDb
let raw = await this.getRawAppointmentInfo(this.page)
// await this.mongoManager.saveRawReserveInfoToDb(raw)
if (raw.email !== undefined) {
this.contact.mail = raw.email
}
if (raw.passportNumber !== undefined) {
this.contact.passportNumber = raw.passportNumber
}
if (raw.lastName !== undefined) {
this.contact.lastName = raw.lastName
}
if (raw.phoneNumber !== undefined) {
this.contact.phoneNumber = raw.phoneNumber
}
if (raw.firstName !== undefined) {
this.contact.firstName = raw.firstName
}
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType);
reserve.source_from = this.device.model();
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())