add method to generate chinese phone number
This commit is contained in:
@@ -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
|
||||
|
||||
phone_number_prefix = ['6']
|
||||
chinnese_number_prefix = ['13', '15', '18']
|
||||
|
||||
|
||||
def read_links_to_click(file_path):
|
||||
@@ -148,13 +149,21 @@ class ExcelHelper:
|
||||
return contact_list
|
||||
|
||||
|
||||
def get_random_phone_numbers():
|
||||
def get_random_fr_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)
|
||||
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:
|
||||
length = 2 # number of characters in the string.
|
||||
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)
|
||||
row = row + 1
|
||||
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.mail = generate_email_from_name(info.first_name, info.last_name)
|
||||
# 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)
|
||||
row = row + 1
|
||||
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.mail = generate_email_from_name(info.first_name, info.last_name)
|
||||
# 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)
|
||||
# excel_reader = ExcelHelper()
|
||||
# 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()
|
||||
# for mail in excel_reader.read_mails_and_pwd():
|
||||
# MONGO_STORE_MANAGER.insert_email(mail)
|
||||
# for i in range(1, 64):
|
||||
# print(get_random_phone_numbers())
|
||||
# for i in range(1, 100):
|
||||
# print(get_random_cn_phone_numbers())
|
||||
|
||||
Reference in New Issue
Block a user