Advertisement
paster442

Automatic Scratch account creation

Feb 25th, 2023 (edited)
617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.14 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.support.ui import Select
  4. from selenium.webdriver.support.ui import WebDriverWait
  5. from selenium.webdriver.support import expected_conditions as EC
  6. from selenium.webdriver.firefox.options import Options
  7. from requests import get
  8. from random import randint
  9. from time import time
  10.  
  11.  
  12. def create_account(username, password, email, random):
  13.     def confirm():
  14.         driver.find_element(By.CSS_SELECTOR, "button.modal-flush-bottom-button[type='submit']").click()
  15.  
  16.  
  17.     driver.get("https://scratch.mit.edu/join")
  18.  
  19.     driver.find_element(By.ID, "username").send_keys(username)
  20.     driver.find_element(By.ID, "password").send_keys(password)
  21.     driver.find_element(By.ID, "passwordConfirm").send_keys(password)
  22.  
  23.     confirm()
  24.  
  25.     if random == True:
  26.         Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "country")))).select_by_index(randint(1, 253))
  27.     else:
  28.         Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "country")))).select_by_index(1)
  29.  
  30.     confirm()
  31.  
  32.     Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "birth_month")))).select_by_value("9")
  33.     Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "birth_year")))).select_by_visible_text("2001")
  34.  
  35.     for _ in range(2):
  36.         confirm()
  37.  
  38.     driver.find_element(By.ID, "email").send_keys(email)
  39.  
  40.     for _ in range(5):
  41.         confirm()
  42.  
  43.  
  44. username = input("Username: ")
  45. password = input("Password: ")
  46. email = input("Email: ")
  47.  
  48.  
  49. yes = 0
  50. if yes == 1:
  51.     driver = webdriver.Firefox()
  52. else:
  53.     options = Options()
  54.     options.add_argument("--headless")
  55.     driver = webdriver.Firefox(options=options)
  56.  
  57.  
  58. start = time()
  59. create_account(username, password, email, random=True)
  60. end = time()
  61.  
  62. if get(f"https://api.scratch.mit.edu/users/{username}/").status_code == 200:
  63.     print(f"@{username} has been created. It took {round(end - start, 3)} seconds to create the account.")
  64.     print(f"https://scratch.mit.edu/users/{username}/")
  65. else:
  66.     print(f"Failed to create @{username}.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement