wordle_archive_solver.py
def main():
    """
    Script to control Chrome Browser to Solve the Wordle Puzzle Archive.
    Input: None
    Output: Solution to the Wordle Puzzle by controlling the browser
    """

    global current_word_list
    global new_word
    current_word_list = load_words("wordle_words.txt")
    allowed_guesses = load_words("wordle_allowed_guesses.txt")

    # Check the Start Word is Valid !!
    if not (start_word in current_word_list or start_word in allowed_guesses) or not (
        len(start_word) == 5
    ):
        rprint("Uh Oh - Please check 'Start Word' \U0001F622")
        rprint(f"Script Execution Time = {time.time() - start_time: .2f} Secs")
        rprint("Scripted by Sachin Shenoy")
        rprint("Twitter: https://twitter.com/sachinshenoy")
        sys.exit()

    # Check the Archive Number is Valid:
    current_wordle_number = (date(2022, 2, 9) - date.today()).days + 235
    rprint((date(2022, 2, 9) - date.today()).days)
    if not (archive_number <= 0) and (archive_number > current_wordle_number):
        rprint("Uh Oh - Invalid Archive Number \U0001F622")
        rprint(f"Script Execution Time = {time.time() - start_time: .2f} Secs")
        rprint("Scripted by Sachin Shenoy")
        rprint("Twitter: https://twitter.com/sachinshenoy")
        sys.exit()

    options = webdriver.ChromeOptions()
    options.add_experimental_option("excludeSwitches", ["enable-logging"])
    options.add_experimental_option("detach", True)

    driver = webdriver.Chrome(options=options)
    driver.get(f"https://www.devangthakkar.com/wordle_archive/?{archive_number}")
    driver.implicitly_wait(5)

    #
    # Close the initial Welcome Screen
    #
    close_button = driver.find_element(
        By.CSS_SELECTOR, "body > div:nth-child(5) > div > div > div > button"
    )
    close_button.click()

    # Turn On Dark Mode
    if dark_mode:
        settings_button = driver.find_element(By.CSS_SELECTOR, "button:nth-child(1)")
        settings_button.click()
        darkmode_button = driver.find_element(By.CSS_SELECTOR, "#headlessui-switch-3")
        darkmode_button.click()
        close_settings = driver.find_element(
            By.CSS_SELECTOR,
            "body > div:nth-child(6) > div > div > div > div > div > button",
        )
        close_settings.click()

    # Send the Start Word
    sendkeys(driver, start_word)
    time.sleep(2)
    row_results = find_bg(driver, 1)
    rprint(row_results)
    new_word = solve_row(row_results, start_word)
    if solution_found(row_results):
        driver.find_element(
            By.CSS_SELECTOR,
            "body > div:nth-child(5) > div > div > div > div > div > button",
        ).click()
        sys.exit()

    # sendkeys(driver, "stomp")
    # time.sleep(3)
    # row_results = find_bg(driver, 2)
    # new_word = solve_row(row_results, "stomp")
    # if solution_found(row_results):
    #     sys.exit()

    for i in range(2, 7):
        sendkeys(driver, new_word)
        time.sleep(2)
        row_results = find_bg(driver, i)
        rprint(row_results)
        if solution_found(row_results):
            driver.find_element(
                By.CSS_SELECTOR,
                "body > div:nth-child(5) > div > div > div > div > div > button",
            ).click()
            sys.exit()
        else:
            new_word = solve_row(row_results, new_word)
    rprint("Uh Oh - Couldn't find the Solution \U0001F622")
    rprint(f"Script Execution Time = {time.time() - start_time: .2f} Secs")

    Script to control Chrome Browser to Solve the Wordle Puzzle Archive.
    Input: None
    Output: Solution to the Wordle Puzzle by controlling the browser
    
Script to control Chrome Browser to Solve the Wordle Puzzle Archive.
Input: None
Output: Solution to the Wordle Puzzle by controlling the browser
Script to control Chrome Browser to Solve the Wordle Puzzle Archive . Input : None Output : Solution to the Wordle Puzzle by controlling the browser
def main():
    global current_word_list
    global new_word
    current_word_list = load_words("wordle_words.txt")
    allowed_guesses = load_words("wordle_allowed_guesses.txt")
    if not (start_word in current_word_list or start_word in allowed_guesses) or not (
        len(start_word) == 5
    ):
        rprint("Uh Oh - Please check 'Start Word' \U0001F622")
        rprint(f"Script Execution Time = {time.time() - start_time: .2f} Secs")
        rprint("Scripted by Sachin Shenoy")
        rprint("Twitter: https://twitter.com/sachinshenoy")
        sys.exit()
    current_wordle_number = (date(2022, 2, 9) - date.today()).days + 235
    rprint((date(2022, 2, 9) - date.today()).days)
    if not (archive_number <= 0) and (archive_number > current_wordle_number):
        rprint("Uh Oh - Invalid Archive Number \U0001F622")
        rprint(f"Script Execution Time = {time.time() - start_time: .2f} Secs")
        rprint("Scripted by Sachin Shenoy")
        rprint("Twitter: https://twitter.com/sachinshenoy")
        sys.exit()
    options = webdriver.ChromeOptions()
    options.add_experimental_option("excludeSwitches", ["enable-logging"])
    options.add_experimental_option("detach", True)
    driver = webdriver.Chrome(options=options)
    driver.get(f"https://www.devangthakkar.com/wordle_archive/?{archive_number}")
    driver.implicitly_wait(5)
     Close the initial Welcome Screen
    close_button = driver.find_element(
        By.CSS_SELECTOR, "body > div:nth-child(5) > div > div > div > button"
    )
    close_button.click()
     Turn On Dark Mode
    if dark_mode:
        settings_button = driver.find_element(By.CSS_SELECTOR, "button:nth-child(1)")
        settings_button.click()
        darkmode_button = driver.find_element(By.CSS_SELECTOR, "headlessui-switch-3")
        darkmode_button.click()
        close_settings = driver.find_element(
            By.CSS_SELECTOR,
            "body > div:nth-child(6) > div > div > div > div > div > button",
        )
        close_settings.click()
     Send the Start Word
    sendkeys(driver, start_word)
    time.sleep(2)
    row_results = find_bg(driver, 1)
    rprint(row_results)
    new_word = solve_row(row_results, start_word)
    if solution_found(row_results):
        driver.find_element(
            By.CSS_SELECTOR,
            "body > div:nth-child(5) > div > div > div > div > div > button",
        ).click()
        sys.exit()
     sendkeys(driver, "stomp")
     time.sleep(3)
     row_results = find_bg(driver, 2)
     new_word = solve_row(row_results, "stomp")
     if solution_found(row_results):
         sys.exit()
    for i in range(2, 7):
        sendkeys(driver, new_word)
        time.sleep(2)
        row_results = find_bg(driver, i)
        rprint(row_results)
        if solution_found(row_results):
            driver.find_element(
                By.CSS_SELECTOR,
                "body > div:nth-child(5) > div > div > div > div > div > button",
            ).click()
            sys.exit()
        else:
            new_word = solve_row(row_results, new_word)
    rprint("Uh Oh - Couldn't find the Solution \U0001F622")
    rprint(f"Script Execution Time = {time.time() - start_time: .2f} Secs")
def main ( ) : global current_word_list global new_word current_word_list = load_words ( "wordle_words.txt" ) allowed_guesses = load_words ( "wordle_allowed_guesses.txt" ) if not ( start_word in current_word_list or start_word in allowed_guesses ) or not ( len ( start_word ) == 5 ) : rprint ( "Uh Oh - Please check 'Start Word' \U0001F622" ) rprint ( f"Script Execution Time = {time.time() - start_time: .2f} Secs" ) rprint ( "Scripted by Sachin Shenoy" ) rprint ( "Twitter: https://twitter.com/sachinshenoy" ) sys . exit ( ) current_wordle_number = ( date ( 2022 , 2 , 9 ) - date . today ( ) ) . days + 235 rprint ( ( date ( 2022 , 2 , 9 ) - date . today ( ) ) . days ) if not ( archive_number <= 0 ) and ( archive_number > current_wordle_number ) : rprint ( "Uh Oh - Invalid Archive Number \U0001F622" ) rprint ( f"Script Execution Time = {time.time() - start_time: .2f} Secs" ) rprint ( "Scripted by Sachin Shenoy" ) rprint ( "Twitter: https://twitter.com/sachinshenoy" ) sys . exit ( ) options = webdriver . ChromeOptions ( ) options . add_experimental_option ( "excludeSwitches" , [ "enable-logging" ] ) options . add_experimental_option ( "detach" , True ) driver = webdriver . Chrome ( options = options ) driver . get ( f"https://www.devangthakkar.com/wordle_archive/?{archive_number}" ) driver . implicitly_wait ( 5 ) close_button = driver . find_element ( By . CSS_SELECTOR , "body > div:nth-child(5) > div > div > div > button" ) close_button . click ( ) if dark_mode : settings_button = driver . find_element ( By . CSS_SELECTOR , "button:nth-child(1)" ) settings_button . click ( ) darkmode_button = driver . find_element ( By . CSS_SELECTOR , "#headlessui-switch-3" ) darkmode_button . click ( ) close_settings = driver . find_element ( By . CSS_SELECTOR , "body > div:nth-child(6) > div > div > div > div > div > button" , ) close_settings . click ( ) sendkeys ( driver , start_word ) time . sleep ( 2 ) row_results = find_bg ( driver , 1 ) rprint ( row_results ) new_word = solve_row ( row_results , start_word ) if solution_found ( row_results ) : driver . find_element ( By . CSS_SELECTOR , "body > div:nth-child(5) > div > div > div > div > div > button" , ) . click ( ) sys . exit ( ) for i in range ( 2 , 7 ) : sendkeys ( driver , new_word ) time . sleep ( 2 ) row_results = find_bg ( driver , i ) rprint ( row_results ) if solution_found ( row_results ) : driver . find_element ( By . CSS_SELECTOR , "body > div:nth-child(5) > div > div > div > div > div > button" , ) . click ( ) sys . exit ( ) else : new_word = solve_row ( row_results , new_word ) rprint ( "Uh Oh - Couldn't find the Solution \U0001F622" ) rprint ( f"Script Execution Time = {time.time() - start_time: .2f} Secs" )
Script to control Chrome Browser to Solve the Wordle Puzzle Archive.
Script to control Chrome Browser to Solve the Wordle Puzzle Archive .
"""
    Script to control Chrome Browser to Solve the Wordle Puzzle Archive.
    Input: None
    Output: Solution to the Wordle Puzzle by controlling the browser
    """ # Check the Start Word is Valid !! # Check the Archive Number is Valid: # # Close the initial Welcome Screen # # Turn On Dark Mode # Send the Start Word # sendkeys(driver, "stomp") # time.sleep(3) # row_results = find_bg(driver, 2) # new_word = solve_row(row_results, "stomp") # if solution_found(row_results): #     sys.exit()