Advertisement
paster442

3

Aug 1st, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.92 KB | None | 0 0
  1. import time, requests, concurrent.futures as cf
  2.  
  3. start_time = time.time()
  4.  
  5. f = open("usernames.txt", "a")
  6. f.truncate() # clear file contents
  7.  
  8. CONNECTIONS = 20
  9.  
  10. def get_usernames():
  11.     my_list = []
  12.  
  13.     alphabet = "abcdefghijklmnopqrstuvwxyz1234567890-_"
  14.     alphabet1 = "opqrstuvwxyz1234567890-_"
  15.     onlyletters = "abcdefghijklmnopqrstuvwxyz"
  16.     nums = "1234567890"
  17.     other = "-_"
  18.    
  19.     for l1 in alphabet1:
  20.         for l2 in alphabet:
  21.             for l3 in alphabet:
  22.                 user = l1 + l2 + l3
  23.                 if not (l1 in onlyletters and l2 in onlyletters and l3 in onlyletters) and not (l1 in other and l2 in other and l3 in other) and not (l1 in nums and l2 in nums and l3 in nums):
  24.                     my_list.append(user)
  25.     return my_list
  26.  
  27. def check_username(username):
  28.     return requests.get(f'https://api.scratch.mit.edu/accounts/checkusername/{username}/').text != '{"username":"' + username + '","msg":"valid username"}'
  29.  
  30. usernames = get_usernames()
  31.  
  32. available_usernames = []
  33. combinations = 25540 # it's actually 25536 but we round it up to 25540 because we can divide 25540 by 10
  34. counter = 0
  35. with cf.ThreadPoolExecutor(max_workers = CONNECTIONS) as executor:
  36.     future_to_url = {executor.submit(check_username, username): username for username in usernames}
  37.     for future in cf.as_completed(future_to_url):
  38.         counter += 1
  39.         if counter % (combinations / 10) == 0:
  40.             print(str(int((counter / combinations) * 100)) + " % done")
  41.         username = future_to_url[future]
  42.         if not future.result():
  43.             available_usernames.append(username)
  44.  
  45. print("100 % done")
  46.  
  47. available_usernames = sorted(available_usernames, key = lambda word: ["abcdefghijklmnopqrstuvwxyz1234567890-_".index(char) for char in word])
  48.  
  49. for item in available_usernames:
  50.     f.write(item + "\n")
  51.  
  52. print("\n" + "Execution time: " + str(round(((time.time() - start_time)/60), 3)) + " minutes")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement