From e9df9a83d91831d5d9c9a4f6c0fa099e2f9465c6 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Fri, 28 Oct 2022 20:54:00 +0200 Subject: [PATCH] use oxylabs to check_results --- src/check_results.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/check_results.py b/src/check_results.py index 7e1ae03..cfca543 100644 --- a/src/check_results.py +++ b/src/check_results.py @@ -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." 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." +CAPTCHA_URL = "https://geo.captcha-delivery.com" # URLs to ignore during checking results BLANK_URL = "about:blank" WELCOME_URL = "https://rendezvousparis.hermes.com/client/welcome" @@ -66,12 +67,12 @@ class ResultChecker: url = reserve_pojo.url print("url is " + url) content = None - proxy = params.get_proxy(ProxyType.RESIDENTIAL) + proxy = params.get_proxy(ProxyType.OXYLABS) device = random.choice(params.DEVICES) self.logger.info("模拟设备: " + device) while content is None: 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("Stopped worker in ", threading.current_thread().name) if SORRY_SENTENCE_FR in content: @@ -92,6 +93,9 @@ class ResultChecker: elif NOT_AVAILABLE_CONTENT in content: print("status is REFUSED") status = ResultEnum.REFUSED + elif CAPTCHA_URL in content: + print("status is BLOCKED") + self.browser.close() else: print("status is ACCEPTED") status = ResultEnum.ACCEPTED @@ -126,10 +130,11 @@ def start_check(reserve_list, firestore_collection, headless: bool, need_send_em count = count + 1 if reserve.accepted is None or ResultEnum.ACCEPTED.value == reserve.accepted: print("will check result") - if reserve.url != BLANK_URL: - if reserve.url != WELCOME_URL: - executor.submit(ResultChecker().run, reserve, firestore_collection, headless, - need_send_email) + if "hotmail" in reserve.email: + if reserve.url != BLANK_URL: + if reserve.url != WELCOME_URL: + executor.submit(ResultChecker().run, reserve, firestore_collection, headless, + need_send_email) else: print("status is " + reserve.accepted)