add method to generate chinese phone number

This commit is contained in:
2023-05-22 23:01:13 +02:00
parent d4febdf96c
commit 2586698ea0
2 changed files with 19 additions and 10 deletions
+4 -4
View File
@@ -199,7 +199,7 @@ class MailReader():
def need_to_valid_url(url: str, successful_items) -> bool: def need_to_valid_url(url: str, successful_items) -> bool:
return True # return True
# if len(successful_items) == 0: # if len(successful_items) == 0:
# return False # return False
print("url is :" + url) print("url is :" + url)
@@ -261,13 +261,13 @@ def read_mails():
# check time before start checking emails # check time before start checking emails
if is_time_between(time(7, 30), time(19, 30)): if is_time_between(time(7, 30), time(19, 30)):
# get email address # get email address
# mail_list = MONGO_STORE_MANAGER.get_destination_emails() mail_list = MONGO_STORE_MANAGER.get_destination_emails()
# excel_reader = ExcelHelper() # excel_reader = ExcelHelper()
# mail_list =excel_reader.read_email_pojo(file_name="/Users/lpan/Desktop/hotmail_list.xlsx") # mail_list =excel_reader.read_email_pojo(file_name="/Users/lpan/Desktop/hotmail_list.xlsx")
mail_address1 = MailAddress(mail="appointment2022@aol.com", password="gyilpmvyyvlcaviq") # mail_address1 = MailAddress(mail="appointment2022@aol.com", password="gyilpmvyyvlcaviq")
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb") # mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
# # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce") # # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
mail_list = [mail_address1] # mail_list = [mail_address1]
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day() successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
mails_messages = [] mails_messages = []
with ThreadPoolExecutor(max_workers=200) as executor: with ThreadPoolExecutor(max_workers=200) as executor:
+15 -6
View File
@@ -13,6 +13,7 @@ from src.pojo.mail.mail_pojo import MailAddress
from src.utils.generate_random_passport_id import get_random_passport_id_number from src.utils.generate_random_passport_id import get_random_passport_id_number
phone_number_prefix = ['6'] phone_number_prefix = ['6']
chinnese_number_prefix = ['13', '15', '18']
def read_links_to_click(file_path): def read_links_to_click(file_path):
@@ -148,13 +149,21 @@ class ExcelHelper:
return contact_list return contact_list
def get_random_phone_numbers(): def get_random_fr_phone_numbers():
length = 8 # number of characters in the string. length = 8 # number of characters in the string.
ran = ''.join(random.choices(string.digits, k=length)) ran = ''.join(random.choices(string.digits, k=length))
id_number = random.choice(phone_number_prefix) + str(ran) id_number = random.choice(phone_number_prefix) + str(ran)
return id_number return id_number
def get_random_cn_phone_numbers():
length = 8 # number of characters in the string.
ran = ''.join(random.choices(string.digits, k=length))
id_number = random.choice(phone_number_prefix) + str(ran)
prefix = random.choice(chinnese_number_prefix)
return prefix + id_number
def generate_email_from_name(first_name: str, last_name: str) -> str: def generate_email_from_name(first_name: str, last_name: str) -> str:
length = 2 # number of characters in the string. length = 2 # number of characters in the string.
ran = ''.join(random.choices(string.digits, k=length)) ran = ''.join(random.choices(string.digits, k=length))
@@ -190,7 +199,7 @@ def write_new_contacts_to_excel(valid_contacts: list, generate_passport=True):
worksheet.write(row, col_num, data, header_format) worksheet.write(row, col_num, data, header_format)
row = row + 1 row = row + 1
for info in valid_contacts: for info in valid_contacts:
info.phone = get_random_phone_numbers() info.phone = get_random_fr_phone_numbers()
info.passport = get_random_passport_id_number() info.passport = get_random_passport_id_number()
info.mail = generate_email_from_name(info.first_name, info.last_name) info.mail = generate_email_from_name(info.first_name, info.last_name)
# Iterate over the data and write it out row by row. # Iterate over the data and write it out row by row.
@@ -215,7 +224,7 @@ def write_destinaire_email(valid_contacts: list, generate_passport=True):
worksheet.write(row, col_num, data, header_format) worksheet.write(row, col_num, data, header_format)
row = row + 1 row = row + 1
for info in valid_contacts: for info in valid_contacts:
info.phone = get_random_phone_numbers() info.phone = get_random_fr_phone_numbers()
info.passport = get_random_passport_id_number() info.passport = get_random_passport_id_number()
info.mail = generate_email_from_name(info.first_name, info.last_name) info.mail = generate_email_from_name(info.first_name, info.last_name)
# Iterate over the data and write it out row by row. # Iterate over the data and write it out row by row.
@@ -242,9 +251,9 @@ if __name__ == '__main__':
# write_new_contacts_to_excel(valid_contacts=contacts) # write_new_contacts_to_excel(valid_contacts=contacts)
# excel_reader = ExcelHelper() # excel_reader = ExcelHelper()
# excel_reader.check_contact_list("/Users/lpan/Desktop/contact_email_valid.xlsx") # excel_reader.check_contact_list("/Users/lpan/Desktop/contact_email_valid.xlsx")
read_links_to_click("/Users/lpan/Downloads/链接.xlsx") read_links_to_click("/Users/lpan/Downloads/links.xlsx")
# save_mails_to_db() # save_mails_to_db()
# for mail in excel_reader.read_mails_and_pwd(): # for mail in excel_reader.read_mails_and_pwd():
# MONGO_STORE_MANAGER.insert_email(mail) # MONGO_STORE_MANAGER.insert_email(mail)
# for i in range(1, 64): # for i in range(1, 100):
# print(get_random_phone_numbers()) # print(get_random_cn_phone_numbers())