import time from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.edge.service import Service from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # Configuration URL = "https://jaksoy.party/soy/" MESSAGE = "Test." EMAIL = "nonoko" # Email to fill in FILE_PATH = r"C:\put_file_path_here" # Use raw string for file path INTERVAL_SECONDS = 10 # Time interval between each post EDGE_DRIVER_PATH = r"filepath_to_edgedriver" # Use raw string for Edge WebDriver path # Initialize the Edge WebDriver service = Service(EDGE_DRIVER_PATH) driver = webdriver.Edge(service=service) def create_thread(): try: # Open the website print("Opening the website...") driver.get(URL) time.sleep(1) # Wait 1 second # Click the "New Thread" button to open the form print("Clicking the 'New Thread' button...") new_thread_button = WebDriverWait(driver, 20).until( EC.element_to_be_clickable((By.CSS_SELECTOR, ".collapse.no-decoration.post-button"))) new_thread_button.click() time.sleep(1) # Wait 1 second # Fill out the "Email" field print("Filling out the 'Email' field...") email_field = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.CSS_SELECTOR, 'input[type="text"][name="email"]'))) email_field.send_keys(EMAIL) time.sleep(1) # Wait 1 second # Fill out the "Message" field print("Filling out the 'Message' field...") message_field = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.ID, "message"))) message_field.send_keys(MESSAGE) time.sleep(1) # Wait 1 second # Upload the file directly using Selenium print("Uploading the file...") file_input = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.CSS_SELECTOR, 'input[type="file"][name="file"]'))) file_input.send_keys(FILE_PATH) # Directly set the file path time.sleep(2) # Wait 2 seconds for the file to be selected # Click the "Submit Thread" button print("Clicking the 'Submit Thread' button...") submit_button = WebDriverWait(driver, 20).until( EC.element_to_be_clickable((By.ID, "submitpost"))) submit_button.click() time.sleep(3) # Wait 3 seconds for submission print("New thread created successfully!") # Refresh the page after submission print("Refreshing the page...") driver.get(URL) time.sleep(2) # Wait 2 seconds after refresh except Exception as e: print(f"An error occurred: {e}") # Run the script forever while True: create_thread() print(f"Waiting for {INTERVAL_SECONDS} seconds before repeating...") time.sleep(INTERVAL_SECONDS)