close browser when exception on validate email

This commit is contained in:
2022-11-06 10:59:02 +01:00
parent b93d40a42f
commit c1f4ee7b6d
2 changed files with 6 additions and 5 deletions
+3 -1
View File
@@ -10,6 +10,7 @@ from builtins import list
from src import params
from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.logs.AppLogging import init_logger
from src.pojo.mail.mail_pojo import MailPojo, MailAddress
from src.proxy.proxy_type import ProxyType
from src.utils.timeutiles import is_time_between
@@ -198,11 +199,12 @@ def read_mails():
if need_to_valid_url(url, successful_items):
url_validator = LinkValidator(url)
print("need to validate url: " + url)
executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), True)
executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
else:
print("do not need to click url --> {}".format(mail.mail_address))
# check whether the url has already been clicked
if __name__ == '__main__':
init_logger()
read_mails()
+3 -4
View File
@@ -52,9 +52,9 @@ class LinkValidator:
# reset otp_value to None
devices = random.choice(params.DEVICES)
first_page = None
while first_page is None:
first_page = self.start_browser(proxy, self.tls.playwright, devices)
proxy = params.get_proxy(self.proxy_type)
# while first_page is None:
self.start_browser(proxy, self.tls.playwright, devices)
# proxy = params.get_proxy(self.proxy_type)
otp_input = self.page.locator(OTP_FIELD_ID)
otp_input.wait_for(state='visible', timeout=TIME_OUT)
self.logger.info("timeout")
@@ -87,7 +87,6 @@ class LinkValidator:
else:
return self.page.content()
except Exception as error:
params.oracle_log_sender.send_error(str(error))
traceback.print_exc(*sys.exc_info())
self.logger.exception(error)
self.logger.info("will close browser")