use stealth_sync

This commit is contained in:
2022-09-06 13:24:27 +02:00
parent 71b77c8b5b
commit 58efbf448a
2 changed files with 15 additions and 2 deletions
+10
View File
@@ -139,6 +139,14 @@ def need_to_valid_url(url: str, successful_items) -> bool:
return False
def need_to_check_email(mail: str, successful_items) -> bool:
for item in successful_items:
if item.email == mail:
if item.url_validated is not None:
return not item.url_validated
return True
def read_mails():
# get email address
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
@@ -154,6 +162,8 @@ def read_mails():
mails_messages = []
with ThreadPoolExecutor(max_workers=20) as executor:
for mail in mail_list:
# check whether we need to read mail
if need_to_check_email(mail, successful_items):
mail_reader = MailReader(mail.mail, mail.password)
executor.submit(mail_reader.read_emails, mails_messages)
+3
View File
@@ -10,6 +10,8 @@ import time
import traceback
from typing import Union
from playwright_stealth import stealth_sync
from src import params, definitions
from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.params import get_random_wait_time
@@ -170,6 +172,7 @@ class CommandorPage:
}});
}
""")
stealth_sync(self.page)
self.page.on("load", self._on_page_loaded)
self.page.on("response", self.handle_response)
self.page.goto(RDV_URL, timeout=PAGE_TIMEOUT)