Merge branch 'master' of bitbucket.org:panleicim/appointment_tool

This commit is contained in:
2022-11-01 22:35:16 +01:00
+11 -6
View File
@@ -25,6 +25,7 @@ NOT_AVAILABLE_CONTENT = "For more than 130 years, our House has offered its full
PENDING_SENTENCE = "Ce soir, entre 20:00 et 20:30, vous obtiendrez une réponse par e-mail." PENDING_SENTENCE = "Ce soir, entre 20:00 et 20:30, vous obtiendrez une réponse par e-mail."
URL_TO_VALID_SENTENCE = "Nous avons envoyé un lien par e-mail." URL_TO_VALID_SENTENCE = "Nous avons envoyé un lien par e-mail."
PENDING_SENTENCE_EN = "This evening between 20:00 and 20:30 you will receive a response by email." PENDING_SENTENCE_EN = "This evening between 20:00 and 20:30 you will receive a response by email."
CAPTCHA_URL = "https://geo.captcha-delivery.com"
# URLs to ignore during checking results # URLs to ignore during checking results
BLANK_URL = "about:blank" BLANK_URL = "about:blank"
WELCOME_URL = "https://rendezvousparis.hermes.com/client/welcome" WELCOME_URL = "https://rendezvousparis.hermes.com/client/welcome"
@@ -66,12 +67,12 @@ class ResultChecker:
url = reserve_pojo.url url = reserve_pojo.url
print("url is " + url) print("url is " + url)
content = None content = None
proxy = params.get_proxy(ProxyType.RESIDENTIAL) proxy = params.get_proxy(ProxyType.OXYLABS)
device = random.choice(params.DEVICES) device = random.choice(params.DEVICES)
self.logger.info("模拟设备: " + device) self.logger.info("模拟设备: " + device)
while content is None: while content is None:
content = self.load_page(self.tls.playwright, proxy, url, device, headless) content = self.load_page(self.tls.playwright, proxy, url, device, headless)
proxy = params.get_proxy(ProxyType.RESIDENTIAL) proxy = params.get_proxy(ProxyType.OXYLABS)
print(content) print(content)
print("Stopped worker in ", threading.current_thread().name) print("Stopped worker in ", threading.current_thread().name)
if SORRY_SENTENCE_FR in content: if SORRY_SENTENCE_FR in content:
@@ -92,6 +93,9 @@ class ResultChecker:
elif NOT_AVAILABLE_CONTENT in content: elif NOT_AVAILABLE_CONTENT in content:
print("status is REFUSED") print("status is REFUSED")
status = ResultEnum.REFUSED status = ResultEnum.REFUSED
elif CAPTCHA_URL in content:
print("status is BLOCKED")
self.browser.close()
else: else:
print("status is ACCEPTED") print("status is ACCEPTED")
status = ResultEnum.ACCEPTED status = ResultEnum.ACCEPTED
@@ -126,10 +130,11 @@ def start_check(reserve_list, firestore_collection, headless: bool, need_send_em
count = count + 1 count = count + 1
if reserve.accepted is None or ResultEnum.ACCEPTED.value == reserve.accepted: if reserve.accepted is None or ResultEnum.ACCEPTED.value == reserve.accepted:
print("will check result") print("will check result")
if reserve.url != BLANK_URL: if "hotmail" in reserve.email:
if reserve.url != WELCOME_URL: if reserve.url != BLANK_URL:
executor.submit(ResultChecker().run, reserve, firestore_collection, headless, if reserve.url != WELCOME_URL:
need_send_email) executor.submit(ResultChecker().run, reserve, firestore_collection, headless,
need_send_email)
else: else:
print("status is " + reserve.accepted) print("status is " + reserve.accepted)