Last active
June 27, 2024 20:19
-
-
Save isaqueprofeta/83b8bc9824b55b63012fa975e7264c25 to your computer and use it in GitHub Desktop.
Fake list of emails using Python Faker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instalar Biblioteca do pip: | |
# - pip instal faker | |
from faker import Faker | |
fake = Faker() | |
# Número de emails | |
number_of_mails = 100 | |
# Lista de domínios | |
list_of_domains = ( | |
'com', | |
'com.br', | |
'net', | |
'net.br', | |
'org', | |
'org.br', | |
'gov', | |
'gov.br' | |
) | |
for _ in range(number_of_mails): | |
# Primeiro nome | |
first_name = fake.first_name() | |
# Segundo nome | |
last_name = fake.last_name() | |
# Empresa, tem que cortar só o primeiro nome | |
# do nome gerado e remover as virgulas | |
# .split()[0] Primeira posição separada por espaços | |
# .strip(',') Limpa as virgulas | |
company = fake.company().split()[0].strip(',') | |
# Gera uma lista de escolhas aleatórias da lista de domínios | |
# limitada a um único valor e tiramos ele da lista | |
dns_org = fake.random_choices( | |
elements=list_of_domains, | |
length=1 | |
)[0] | |
# Formata o email no formato [email protected] | |
# todo em minúsculas | |
email = f"{first_name}.{last_name}@{company}.{dns_org}".lower() | |
# Imprime o e-mail | |
print(email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing 🙌