mail reader optimization
This commit is contained in:
@@ -243,9 +243,6 @@ def read_mails():
|
||||
# excel_reader = ExcelHelper()
|
||||
# mail_list = excel_reader.read_email_pojo(file_name="/Users/panlei/Downloads/hotmail_list.xlsx")
|
||||
# mail_address1 = MailAddress(mail="quaveraidv@hotmail.com", password="2iB60x20")
|
||||
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
||||
# mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
|
||||
# mail_address3 = MailAddress(mail="shenpeiyun@naver.com", password="Rdv@20222021")
|
||||
# mail_list = [mail_address1]
|
||||
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
mails_messages = []
|
||||
@@ -256,6 +253,7 @@ def read_mails():
|
||||
mail_reader = MailReader(mail.mail, mail.password)
|
||||
executor.submit(mail_reader.read_emails, mails_messages)
|
||||
# get ip_country info
|
||||
_refreshed_successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
_all_contact_list = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
for mail in mails_messages:
|
||||
@@ -269,7 +267,7 @@ def read_mails():
|
||||
# url = "https://rendezvousparis.hermes.com/" + url_to_validate.replace("3D", "")
|
||||
# else:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, successful_items):
|
||||
if need_to_valid_url(url, _refreshed_successful_items):
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address, _all_contact_list)
|
||||
# url_validator = LinkValidator(url)
|
||||
print("need to validate url: " + url)
|
||||
|
||||
@@ -206,16 +206,12 @@ def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
parts = url.split('/')
|
||||
id = parts[5]
|
||||
if len(id) == 6:
|
||||
if id == "CS93VB":
|
||||
print("found")
|
||||
for item in successful_items:
|
||||
if item.id == id:
|
||||
if item.url_validated is not None:
|
||||
return not item.url_validated
|
||||
else:
|
||||
# if url_validated is None
|
||||
if item.url_validated is not None:
|
||||
return not item.url_validated
|
||||
return True
|
||||
return True
|
||||
else:
|
||||
@@ -280,7 +276,8 @@ def read_all_mails():
|
||||
if need_to_check_email(mail.mail, successful_items):
|
||||
mail_reader = MailReader(mail.mail, mail.password)
|
||||
executor.submit(mail_reader.read_emails, mails_messages)
|
||||
|
||||
# 在读邮件时候,可能会有其他的约会提交或者约会的链接确认,所以需要刷新一下成功的列表
|
||||
_refreshed_successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
for mail in mails_messages:
|
||||
# if mail.isImapClient:
|
||||
@@ -293,9 +290,10 @@ def read_all_mails():
|
||||
# url = "https://rendezvousparis.hermes.com/" + url_to_validate.replace("3D", "")
|
||||
# else:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, successful_items):
|
||||
if need_to_valid_url(url, _refreshed_successful_items):
|
||||
print("need to validate url: " + url)
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address,_all_contact_list=contact_to_book_list)
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address,
|
||||
_all_contact_list=contact_to_book_list)
|
||||
# url_validator = LinkValidator(url)
|
||||
# executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user