from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
import random
import string
def generate_username():
"""Generates a random username."""
adjective = ["Cool", "Super", "Mystery"]
noun = ["Coder", "Bot", "User"]
number = str(random.randint(100, 999))
return random.choice(adjective) + random.choice(noun) + number
def generate_password(length=12):
"""Generates a random password."""
characters = string.ascii_letters + string.digits + string.punctuation
return ''.join(random.choice(characters) for i in range(length))
def read_emails_from_file(filename="email.txt"):
"""Reads email addresses from a file, returning a list."""
with open(filename, "r") as file:
emails = [line.strip() for line in file.readlines()]
return emails
def save_account_details(username, email, password, filename="reddit.txt"):
"""Saves the account details to a file."""
with open(filename, "a") as file:
file.write(f"{username},{email},{password}\n")
def create_accounts(emails):
for email in emails:
driver = webdriver.Chrome() # or use Firefox()
driver.get("https://www.reddit.com/register/")
time.sleep(random.uniform(1.5, 3.0))
username = generate_username()
password = generate_password()
username_field = driver.find_element_by_id("regUsername")
password_field = driver.find_element_by_id("regPassword")
email_field = driver.find_element_by_id("regEmail")
action = ActionChains(driver)
action.send_keys_to_element(username_field, username)
action.send_keys_to_element(password_field, password)
action.send_keys_to_element(email_field, email)
action.perform()
sign_up_button = driver.find_element_by_css_selector("button.sign-up") # Adjust the selector as needed
sign_up_button.click()
# Assuming account creation was successful without further validation
save_account_details(username, email, password)
driver.quit() # Close the browser after each account creation
if __name__ == "__main__":
emails = read_emails_from_file()
create_accounts(emails)