support serial
This commit is contained in:
@@ -9,9 +9,11 @@ from src.pojo.contact_pojo import ContactPojo
|
|||||||
from src.utils.contacts.generate_random_passport_id import get_random_passport_id_number
|
from src.utils.contacts.generate_random_passport_id import get_random_passport_id_number
|
||||||
from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_random_fr_phone_numbers, ExcelHelper
|
from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_random_fr_phone_numbers, ExcelHelper
|
||||||
|
|
||||||
|
DEFAULT_SERIAL = "47e7e36b"
|
||||||
|
|
||||||
|
|
||||||
def upload_contacts_list():
|
def upload_contacts_list():
|
||||||
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-09-27_today.xlsx")
|
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-09-28.xlsx")
|
||||||
return _contacts_to_book
|
return _contacts_to_book
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +63,7 @@ def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.dat
|
|||||||
col = 0
|
col = 0
|
||||||
# Create a workbook and add a worksheet.
|
# Create a workbook and add a worksheet.
|
||||||
workbook = xlsxwriter.Workbook('contact_list_{}.xlsx'.format(file_name))
|
workbook = xlsxwriter.Workbook('contact_list_{}.xlsx'.format(file_name))
|
||||||
header_data = ['name', 'phone', 'passport', 'email', 'store', 'ip_country', 'ua']
|
header_data = ['name', 'phone', 'passport', 'email', 'store', 'serial', 'ip_country', 'ua']
|
||||||
worksheet = workbook.add_worksheet()
|
worksheet = workbook.add_worksheet()
|
||||||
header_format = workbook.add_format({'bold': True})
|
header_format = workbook.add_format({'bold': True})
|
||||||
|
|
||||||
@@ -75,14 +77,16 @@ def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.dat
|
|||||||
worksheet.write(row, col + 2, info.passport)
|
worksheet.write(row, col + 2, info.passport)
|
||||||
worksheet.write(row, col + 3, info.mail)
|
worksheet.write(row, col + 3, info.mail)
|
||||||
worksheet.write(row, col + 4, info.store)
|
worksheet.write(row, col + 4, info.store)
|
||||||
worksheet.write(row, col + 5, info.ip_country)
|
worksheet.write(row, col + 5, info.serial)
|
||||||
worksheet.write(row, col + 6, info.ua)
|
worksheet.write(row, col + 6, info.ip_country)
|
||||||
|
worksheet.write(row, col + 7, info.ua)
|
||||||
row += 1
|
row += 1
|
||||||
workbook.close()
|
workbook.close()
|
||||||
|
|
||||||
|
|
||||||
def generate_valid_contact_list_for_day(segment_number=1):
|
def generate_valid_contact_list_for_day(segment_number=1):
|
||||||
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
_collection_name = "2024-09-23"
|
||||||
|
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_one_day(_collection_name)
|
||||||
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
||||||
_contact_to_save = []
|
_contact_to_save = []
|
||||||
for _contact in _valid_contact_list:
|
for _contact in _valid_contact_list:
|
||||||
@@ -96,6 +100,8 @@ def generate_valid_contact_list_for_day(segment_number=1):
|
|||||||
_contact.passport = _true_contact.passport
|
_contact.passport = _true_contact.passport
|
||||||
_contact.first_name = _true_contact.first_name
|
_contact.first_name = _true_contact.first_name
|
||||||
|
|
||||||
|
if len(_contact.serial) == 0:
|
||||||
|
_contact.serial = DEFAULT_SERIAL
|
||||||
if _contact.url_validated:
|
if _contact.url_validated:
|
||||||
if _contact.last_name is not None and len(_contact.last_name) > 0:
|
if _contact.last_name is not None and len(_contact.last_name) > 0:
|
||||||
_need_to_save = True
|
_need_to_save = True
|
||||||
@@ -107,14 +113,15 @@ def generate_valid_contact_list_for_day(segment_number=1):
|
|||||||
and _added_item.last_name == _contact.last_name
|
and _added_item.last_name == _contact.last_name
|
||||||
and _added_item.first_name == _contact.first_name):
|
and _added_item.first_name == _contact.first_name):
|
||||||
_need_to_save = False
|
_need_to_save = False
|
||||||
|
|
||||||
if _need_to_save:
|
if _need_to_save:
|
||||||
_contact_to_save.append(_contact)
|
_contact_to_save.append(_contact)
|
||||||
_contact_to_save_list = _contact_to_save
|
_contact_to_save_list = _contact_to_save
|
||||||
write_new_contacts_to_excel(_contact_to_save_list)
|
write_new_contacts_to_excel(_contact_to_save_list, file_name=_collection_name)
|
||||||
for i in range(0, segment_number):
|
for i in range(0, segment_number):
|
||||||
_step = int(len(_contact_to_save_list) / segment_number)
|
_step = int(len(_contact_to_save_list) / segment_number)
|
||||||
_sublist = _contact_to_save_list[i * _step:_step * (i + 1)]
|
_sublist = _contact_to_save_list[i * _step:_step * (i + 1)]
|
||||||
_file_name = str(datetime.date.today()) + "_" + str(i + 1)
|
_file_name = _collection_name + "_" + str(i + 1)
|
||||||
write_new_contacts_to_excel(_sublist, file_name=_file_name)
|
write_new_contacts_to_excel(_sublist, file_name=_file_name)
|
||||||
|
|
||||||
|
|
||||||
@@ -150,7 +157,7 @@ def update_contact_list_not_received_mail():
|
|||||||
write_to_black_list([_contact])
|
write_to_black_list([_contact])
|
||||||
|
|
||||||
|
|
||||||
def get_old_validated_contact_list(remove_blacklisted_contact=True, _day_in_str="2024-09-09"):
|
def get_old_validated_contact_list(remove_blacklisted_contact=True, _day_in_str="2024-09-06"):
|
||||||
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_one_day(_day_in_str)
|
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_one_day(_day_in_str)
|
||||||
_domain_list_to_remove = ["firemail.de", "onet.pl", "yahoo.com", "gmx.com"]
|
_domain_list_to_remove = ["firemail.de", "onet.pl", "yahoo.com", "gmx.com"]
|
||||||
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
||||||
@@ -193,10 +200,10 @@ def get_old_validated_contact_list(remove_blacklisted_contact=True, _day_in_str=
|
|||||||
|
|
||||||
# 把新的联系人存到网上
|
# 把新的联系人存到网上
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
contacts_to_book = upload_contacts_list()
|
# contacts_to_book = upload_contacts_list()
|
||||||
MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
|
# MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
|
||||||
# print("start at {}".format(datetime.datetime.now()))
|
# print("start at {}".format(datetime.datetime.now()))
|
||||||
# generate_valid_contact_list_for_day(segment_number=2)
|
generate_valid_contact_list_for_day(segment_number=2)
|
||||||
# generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx")
|
# generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx")
|
||||||
# print("end at {}".format(datetime.datetime.now()))
|
# print("end at {}".format(datetime.datetime.now()))
|
||||||
# update_contact_list_not_received_mail()
|
# update_contact_list_not_received_mail()
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class ReserveResultPojo:
|
|||||||
validated_at = None
|
validated_at = None
|
||||||
ip_address = None
|
ip_address = None
|
||||||
ua = ""
|
ua = ""
|
||||||
|
serial = ""
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash("{}".format(self.mail))
|
return hash("{}".format(self.mail))
|
||||||
@@ -102,6 +103,9 @@ class ReserveResultPojo:
|
|||||||
if 'accepted' in source:
|
if 'accepted' in source:
|
||||||
accepted = source['accepted']
|
accepted = source['accepted']
|
||||||
result.accepted = accepted
|
result.accepted = accepted
|
||||||
|
if 'serial' in source:
|
||||||
|
serial = source['serial']
|
||||||
|
result.serial = serial
|
||||||
if 'message' in source:
|
if 'message' in source:
|
||||||
message = source['message']
|
message = source['message']
|
||||||
result.message = message
|
result.message = message
|
||||||
|
|||||||
Reference in New Issue
Block a user