Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. from random import randint
  2.  
  3. class Account:
  4.     def __init__(self, email, passw):
  5.         self.email = email
  6.         self.passw = passw
  7.  
  8.  
  9. class AccountLoader:
  10.     def __init__(self):
  11.         self.accounts = []
  12.  
  13.     @staticmethod
  14.     def parse_line_to_account(line):
  15.         _line = line.split(':')
  16.         return _line[0], _line[1]
  17.  
  18.     def load_accounts_from_file(self):
  19.         _accounts_list = [line.strip() for line in open('accounts.txt')]
  20.         for _account in _accounts_list:
  21.             self.accounts.append(Account(*self.parse_line_to_account(_account)))
  22.  
  23.     def get_random_account(self):
  24.         r = randint(0, len(self.accounts))
  25.         return self.accounts[r-1]
  26.  
  27. al = AccountLoader()
  28. al.load_accounts_from_file()
  29.  
  30. #Example
  31. for i in range(1,10):
  32.     #10 razy randomowe konto chcemy
  33.     random_account = al.get_random_account()
  34.     print(random_account.email, random_account.passw)
  35.     #przykładowo
  36.     #element.send_keys(random_account.email)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement