|
| 1 | +from random import choice, randint |
| 2 | +from faker import Faker |
| 3 | +import re |
| 4 | + |
| 5 | +FAKER = Faker('pt-br') |
| 6 | + |
| 7 | +# links dos emails |
| 8 | +EMAIL_LINKS= ['yahoo.com', 'yahoo.com.br', |
| 9 | + 'outlook.com', 'outlook.com.br', |
| 10 | + 'hotmail.com', 'hotmail.com.br', |
| 11 | + 'gmail.com', 'icloud.com', 'aol.com', |
| 12 | + 'live.com', 'bol.com.br', 'uol.com.br', |
| 13 | + 'terra.com.br', 'ig.com.br', 'r7.com', |
| 14 | + 'zipmail.com.br','protonmail.com','yandex.com'] |
| 15 | + |
| 16 | +# remove palavras com acentos e siglas |
| 17 | +def remove_things(word:str) -> str: |
| 18 | + chars = { |
| 19 | + 'á':'a', |
| 20 | + 'é':'e', |
| 21 | + 'í':'i', |
| 22 | + 'ó':'o', |
| 23 | + 'ú':'u', |
| 24 | + 'ñ':'n', |
| 25 | + 'ỹ':'y', |
| 26 | + 'ý':'y', |
| 27 | + 'ã':'a', |
| 28 | + 'ẽ':'e', |
| 29 | + 'ĩ':'i', |
| 30 | + 'õ':'o', |
| 31 | + 'ũ':'u', |
| 32 | + 'ç':'c', |
| 33 | + 'à':'a', |
| 34 | + 'è':'e', |
| 35 | + 'ì':'i', |
| 36 | + 'ò':'o', |
| 37 | + 'ù':'u', |
| 38 | + 'â':'a', |
| 39 | + 'ê':'e', |
| 40 | + 'î':'i', |
| 41 | + 'ô':'o', |
| 42 | + 'û':'u', |
| 43 | + 'ŷ':'y', |
| 44 | + 'ĉ':'c', |
| 45 | + 'ŝ':'s', |
| 46 | + 'ĵ':'j', |
| 47 | + |
| 48 | + |
| 49 | + 'dra\.\s': '', |
| 50 | + 'dr\.\s': '', |
| 51 | + 'sr\.\s': '', |
| 52 | + 'sra\.\s': '', |
| 53 | + 'srta\.\s': '', |
| 54 | + } |
| 55 | + |
| 56 | + for k, v in chars.items(): |
| 57 | + # print(k, v, '=', word) |
| 58 | + # print(k, v, '=', word) |
| 59 | + word = re.sub(k, v, word) |
| 60 | + return word |
| 61 | + |
| 62 | +# gera um email utilizando nome |
| 63 | +def generate_email(nome:str='', date:str=''): |
| 64 | + if not nome: nome = FAKER.name() |
| 65 | + |
| 66 | + nome = nome.lower() |
| 67 | + nome = remove_things(nome) |
| 68 | + nome = nome.split(' ') |
| 69 | + # print(nome) |
| 70 | + q:list = [True, False] |
| 71 | + if choice(q): |
| 72 | + if choice(q): |
| 73 | + for i, n in enumerate(nome): |
| 74 | + if choice(q) and i == 0: |
| 75 | + nome[0] = n[:2] |
| 76 | + elif choice(q): |
| 77 | + nome[i] = n[:4] |
| 78 | + else: |
| 79 | + nome[i] = n[:3] |
| 80 | + elif choice(q): |
| 81 | + nome[0] = nome[0][:2] |
| 82 | + |
| 83 | + # data de nascimento |
| 84 | + |
| 85 | + date = date.split(('/' if '/' in date else '-')) |
| 86 | + if choice(q): |
| 87 | + date = date[0] if len(date[0]) == 4 else date[-1] |
| 88 | + else: |
| 89 | + date = '' |
| 90 | + # ------------------- |
| 91 | + |
| 92 | + if choice(q): |
| 93 | + nome = nome[0], nome[-1] |
| 94 | + nome = '.'.join(nome) |
| 95 | + else: |
| 96 | + nome = ''.join(nome) |
| 97 | + |
| 98 | + return nome +date+'@' + choice(EMAIL_LINKS) |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +def gen_date(): |
| 103 | + dia = str(randint(0, 30)) |
| 104 | + mes = str(randint(1, 12)) |
| 105 | + ano = str(randint(1990, 2010)) |
| 106 | + return f'{dia}/{mes}/{ano}' |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | +# for i in range(200): |
| 113 | +# date = gen_date() |
| 114 | +# nome = FAKER.name() |
| 115 | +# email = generate_email(nome, date) |
| 116 | +# print('email:', email) |
| 117 | +# print(' nome:', nome) |
| 118 | +# print('----------------------') |
| 119 | + |
| 120 | +for _ in range(10): |
| 121 | + email = generate_email() |
| 122 | + print('|>'+email+'<|') |
| 123 | + print('-'*len(email)+'----') |
| 124 | + |
| 125 | +# nome = 'Dra. Letícia da Costa' |
| 126 | +# email = generate_email(nome) |
| 127 | +# print(email) |
| 128 | +# nome = 'Sr. Daniel Rocha' |
| 129 | +# email = generate_email(nome) |
| 130 | +# print(email, nome) |
| 131 | +# nome = 'Dr. Luiz Otávio da Costa' |
| 132 | +# email = generate_email(nome) |
| 133 | +# print(email, '|nome:' + nome) |
| 134 | +# nome = 'Srta. Alice Sales' |
| 135 | +# email = generate_email(nome) |
| 136 | +# print(email, '|nome:' + nome) |
| 137 | +# Ana Laura Rocha |
| 138 | + |
0 commit comments