add regex for url
This commit is contained in:
@@ -28,6 +28,7 @@ const TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests"
|
|||||||
const TOO_MANY_REQUEST_ERROR_MESSAGE_FR = "Suite à un trop grand nombre de demandes"
|
const TOO_MANY_REQUEST_ERROR_MESSAGE_FR = "Suite à un trop grand nombre de demandes"
|
||||||
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
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é"
|
||||||
|
REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
||||||
|
|
||||||
function delay(delayInms) {
|
function delay(delayInms) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -66,6 +67,10 @@ class CommandorPage {
|
|||||||
this.page.on("load", (loadedPage) => {
|
this.page.on("load", (loadedPage) => {
|
||||||
this.onPageLoad(loadedPage)
|
this.onPageLoad(loadedPage)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.page.on("response", (response) => {
|
||||||
|
this.onResponse(response)
|
||||||
|
})
|
||||||
await this.page.goto(RDV_URL);
|
await this.page.goto(RDV_URL);
|
||||||
//wait 10 mins
|
//wait 10 mins
|
||||||
// Close the device.
|
// Close the device.
|
||||||
@@ -209,6 +214,13 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onResponse(response) {
|
||||||
|
let rex = new RegExp(REGEX_RDV_URL)
|
||||||
|
if (rex.test(response.url)) {
|
||||||
|
console.log("rdv url found:" + response.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async push_message_to_queue(publishType) {
|
async push_message_to_queue(publishType) {
|
||||||
let url = this.page.url();
|
let url = this.page.url();
|
||||||
let splitedUrl = url.split("/");
|
let splitedUrl = url.split("/");
|
||||||
@@ -222,6 +234,8 @@ class CommandorPage {
|
|||||||
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = CommandorPage
|
module.exports = CommandorPage
|
||||||
Reference in New Issue
Block a user