Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import Select
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from selenium.webdriver.firefox.options import Options
- from requests import get
- from random import randint
- from time import time
- def create_account(username, password, email, random):
- def confirm():
- driver.find_element(By.CSS_SELECTOR, "button.modal-flush-bottom-button[type='submit']").click()
- driver.get("https://scratch.mit.edu/join")
- driver.find_element(By.ID, "username").send_keys(username)
- driver.find_element(By.ID, "password").send_keys(password)
- driver.find_element(By.ID, "passwordConfirm").send_keys(password)
- confirm()
- if random == True:
- Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "country")))).select_by_index(randint(1, 253))
- else:
- Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "country")))).select_by_index(1)
- confirm()
- Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "birth_month")))).select_by_value("9")
- Select(WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "birth_year")))).select_by_visible_text("2001")
- for _ in range(2):
- confirm()
- driver.find_element(By.ID, "email").send_keys(email)
- for _ in range(5):
- confirm()
- username = input("Username: ")
- password = input("Password: ")
- email = input("Email: ")
- yes = 0
- if yes == 1:
- driver = webdriver.Firefox()
- else:
- options = Options()
- options.add_argument("--headless")
- driver = webdriver.Firefox(options=options)
- start = time()
- create_account(username, password, email, random=True)
- end = time()
- if get(f"https://api.scratch.mit.edu/users/{username}/").status_code == 200:
- print(f"@{username} has been created. It took {round(end - start, 3)} seconds to create the account.")
- print(f"https://scratch.mit.edu/users/{username}/")
- else:
- print(f"Failed to create @{username}.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement