#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @Contact : liuyuqi.gov@msn.cn @Time : 2023/03/26 15:40:11 @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved. @Desc : generate email and password ''' import random import argparse argparser = argparse.ArgumentParser() argparser.add_argument("-n", "--number", help="number of email to generate, default is 5", default="5") argparser.add_argument("-sfx", "--suffix", help="email suffix, default is @outlook.com", default="@outlook.com") args = argparser.parse_args() initList = [] compose_account = [] def generate_email(number: int, suffix: str) -> None: with open(("data/b.csv"), "r", encoding="utf-8") as f: csv_data = f.readlines() for row in csv_data: initList.append(row.strip()) index = 1 # random choose 3 from initList, and join them while index <= number: name = "".join(random.sample(initList, 2)) account = name + str(random.randint(100, 999)) password = ''.join(random.sample( 'abcdefghijklmnopqrstuvwxyz0123456789_', 12)) compose_account.append({"email": account+suffix, "password": password}) index += 1 return compose_account def write_to_file(): with open("res.txt", "a+", encoding="utf-8") as file: for i in compose_account: file.write(i["email"] + " " + i["password"]+"\n") def main(): generate_email(number,suffix=args.suffix) write_to_file() if __name__ == '__main__': if args.number: if args.number.isdigit() and int(args.number) > 0 and int(args.number) < 1000: number = int(args.number) else: print("please input a number between 1 and 1000") exit(1) main()