optimization when error

This commit is contained in:
PAN Lei
2022-05-20 13:46:47 +02:00
parent c056445268
commit 8444ea2c11
6 changed files with 20 additions and 7 deletions
+10 -1
View File
@@ -1,5 +1,6 @@
import logging
import random
import re
import string
import threading
import time
@@ -17,6 +18,7 @@ RDV_URL = "https://rendezvousparis.hermes.com/client/register"
# RDV_URL = "file:///Users/lpan/Downloads/test_appointment.html"
# RDV_URL = "https://api.ipify.org"
# RDV_URL ="https://bot.sannysoft.com/"
REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
otp_value = None
OTP_FIELD_ID = "#sms_code"
MESSAGE_FIELD_CLASS = ".message"
@@ -26,7 +28,7 @@ DOUBLE_REQUEST_ERROR_MESSAGE = "A request with the same data has already been va
TOO_MANY_REQUEST_ERROR_MESSAGE = "Due to a large number of requests"
TIME_OUT = 400000
OTP_TIMEOUT = 240
PAGE_TIMEOUT = 20000
PAGE_TIMEOUT = 30000
def get_random_wait_time() -> float:
@@ -138,6 +140,7 @@ class CommandorPage:
}
""")
self.page.on("load", self._on_page_loaded)
self.page.on("response", self.handle_response)
self.page.goto(RDV_URL, timeout=PAGE_TIMEOUT)
return self.page.content()
except Exception as error:
@@ -147,6 +150,12 @@ class CommandorPage:
self.browser.close()
return None
def handle_response(self, response):
pattern = re.compile(REGEX_RDV_URL)
if pattern.match(response.url):
self.logger.info("result url found: " + response.url)
self.publish_message_to_queue(self.contact, PublishType.PENDING, response.url)
def start_page(self, proxy):
e = threading.Event()
self._run(e, proxy)