use stealth_sync
This commit is contained in:
@@ -139,6 +139,14 @@ def need_to_valid_url(url: str, successful_items) -> bool:
|
|||||||
return False
|
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():
|
def read_mails():
|
||||||
# get email address
|
# get email address
|
||||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||||
@@ -154,6 +162,8 @@ def read_mails():
|
|||||||
mails_messages = []
|
mails_messages = []
|
||||||
with ThreadPoolExecutor(max_workers=20) as executor:
|
with ThreadPoolExecutor(max_workers=20) as executor:
|
||||||
for mail in mail_list:
|
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)
|
mail_reader = MailReader(mail.mail, mail.password)
|
||||||
executor.submit(mail_reader.read_emails, mails_messages)
|
executor.submit(mail_reader.read_emails, mails_messages)
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
from playwright_stealth import stealth_sync
|
||||||
|
|
||||||
from src import params, definitions
|
from src import params, definitions
|
||||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||||
from src.params import get_random_wait_time
|
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("load", self._on_page_loaded)
|
||||||
self.page.on("response", self.handle_response)
|
self.page.on("response", self.handle_response)
|
||||||
self.page.goto(RDV_URL, timeout=PAGE_TIMEOUT)
|
self.page.goto(RDV_URL, timeout=PAGE_TIMEOUT)
|
||||||
|
|||||||
Reference in New Issue
Block a user