add method to extract contact list with serial
This commit is contained in:
@@ -12,6 +12,7 @@ from imapclient import IMAPClient
|
||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||
from src.logs.AppLogging import init_logger
|
||||
from src.mail.mail_constants import DOMAIN_HOTMAIL, create_imap
|
||||
from src.mail.mail_reader import need_to_valid_url
|
||||
from src.pojo.mail.mail_pojo import MailPojo
|
||||
from src.utils.timeutiles import is_time_between
|
||||
|
||||
@@ -200,25 +201,25 @@ class MailReader():
|
||||
return mail_messages
|
||||
|
||||
|
||||
def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
# return True
|
||||
# if len(successful_items) == 0:
|
||||
# return False
|
||||
print("url is :" + url)
|
||||
parts = url.split('/')
|
||||
id = parts[5]
|
||||
if len(id) == 6:
|
||||
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
|
||||
return True
|
||||
return True
|
||||
else:
|
||||
print("id not valid:{}".format(id))
|
||||
return False
|
||||
# def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
# # return True
|
||||
# # if len(successful_items) == 0:
|
||||
# # return False
|
||||
# print("url is :" + url)
|
||||
# parts = url.split('/')
|
||||
# id = parts[5]
|
||||
# if len(id) == 6:
|
||||
# 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
|
||||
# return True
|
||||
# return True
|
||||
# else:
|
||||
# print("id not valid:{}".format(id))
|
||||
# return False
|
||||
|
||||
|
||||
def need_to_check_email(mail: str, successful_items) -> bool:
|
||||
@@ -281,6 +282,8 @@ def read_all_mails(contact_to_book_list=None):
|
||||
executor.submit(mail_reader.read_emails, mails_messages)
|
||||
# 在读邮件时候,可能会有其他的约会提交或者约会的链接确认,所以需要刷新一下成功的列表
|
||||
_refreshed_successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
contact_serial_map_list = MONGO_STORE_MANAGER.get_all_contact_serial_list()
|
||||
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
for mail in mails_messages:
|
||||
match = re.search(VALIDATION_URL_REGEX, mail.body)
|
||||
@@ -290,10 +293,12 @@ def read_all_mails(contact_to_book_list=None):
|
||||
# url = "https://rendezvousparis.hermes.com/" + url_to_validate.replace("3D", "")
|
||||
# else:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, _refreshed_successful_items):
|
||||
_item, is_need_to = need_to_valid_url(url, _refreshed_successful_items)
|
||||
if is_need_to:
|
||||
print("need to validate url: " + url)
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address,
|
||||
_all_contact_list=contact_to_book_list)
|
||||
_all_contact_list=contact_to_book_list, _item=_item,
|
||||
contact_serial_map_list=contact_serial_map_list)
|
||||
else:
|
||||
print("do not need to click url --> {}".format(mail.mail_address))
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ class ReserveResultPojo:
|
||||
if 'source_from' in source:
|
||||
source_from = source['source_from']
|
||||
result.source_from = source_from
|
||||
result.model = source_from
|
||||
if 'sim_position' in source:
|
||||
sim_position = source['sim_position']
|
||||
result.sim_position = sim_position
|
||||
|
||||
@@ -16,6 +16,7 @@ class ContactPojo:
|
||||
isp: str = None
|
||||
ua: str = ""
|
||||
serial: str = ""
|
||||
model: str = ""
|
||||
|
||||
def __repr__(self):
|
||||
return "phone:{}, passport:{}, last_name:{}, first_name:{}, mail:{}, store:{}, ip_country:{},isp:{}".format(
|
||||
@@ -79,5 +80,8 @@ class ContactPojo:
|
||||
if source.get('serial'):
|
||||
serial = source['serial']
|
||||
result.serial = serial
|
||||
if source.get('source_from'):
|
||||
model = source['source_from']
|
||||
result.model = model
|
||||
result.ua = ua
|
||||
return result
|
||||
|
||||
@@ -75,7 +75,7 @@ def generate_not_used_contact_list():
|
||||
|
||||
|
||||
def upload_to_collection():
|
||||
_contacts = read_contacts(str(Path.home()) + "/Desktop/contact_list_contacts_with_source.xlsx")
|
||||
_contacts = read_contacts(str(Path.home()) + "/Desktop/contact_list_2024-11-05.xlsx")
|
||||
MONGO_STORE_MANAGER.upload_contact_list_to_collection(_contacts,"CONTACT_LIST_SERIAL_MAP")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user