15
15
16
16
# Check word length
17
17
def check_word_length (word ):
18
- if len (word ) != 6 :
18
+ if len (word ) != 5 :
19
19
return False
20
20
else :
21
21
return True
22
22
23
23
24
- list_of_words = open ("words_alpha.txt" , "r" ).read ().splitlines ()
24
+ list_of_words = open ("words_alpha.txt" , "r" ).read ().strip (). splitlines ()
25
25
list_of_words = list (filter (check_word_length , list_of_words ))
26
26
27
27
28
28
def on_release (key ):
29
+ # Start button
29
30
if key == keyboard .Key .esc :
30
31
return False # stop listener
31
32
32
33
33
- def get_wordle_evaluation (game_row , browser ):
34
+ def get_row_results (game_row ):
34
35
tiles = game_row .find_elements (By .CLASS_NAME , "Tile-module_tile__3ayIZ" )
35
36
evaluation = []
36
37
eval_to_int = {
@@ -46,8 +47,15 @@ def get_wordle_evaluation(game_row, browser):
46
47
return tuple (evaluation )
47
48
48
49
50
+ def enter_word (word ):
51
+ keyboard_controller = keyboard .Controller ()
52
+ keyboard_controller .type (word )
53
+ keyboard_controller .tap (keyboard .Key .enter )
54
+ time .sleep (2 )
55
+
56
+
49
57
def main ():
50
- start_button = 'esc'
58
+ # Start the browser
51
59
browser = webdriver .Firefox (service = FirefoxService (GeckoDriverManager ().install ()))
52
60
browser .get ("https://www.nytimes.com/games/wordle/index.html" )
53
61
@@ -56,26 +64,18 @@ def main():
56
64
listener .join ()
57
65
print ("Starting" )
58
66
59
- first_string = "moron"
60
- keyboard_controller = keyboard .Controller ()
61
- keyboard_controller .type (first_string )
62
- keyboard_controller .tap (keyboard .Key .enter )
63
-
64
- time .sleep (2 )
65
-
67
+ # Get the game rows
66
68
game_rows = browser .find_elements (By .CLASS_NAME , 'Row-module_row__dEHfN' )
67
- # print("Game rows: ", len(game_rows))
68
- get_wordle_evaluation (game_rows [0 ], browser )
69
69
70
- time .sleep (1 )
70
+ first_string = "tests"
71
+ enter_word (first_string )
72
+ get_row_results (game_rows [0 ])
71
73
72
- second_string = "tests"
73
- keyboard_controller .type (second_string )
74
- keyboard_controller .tap (keyboard .Key .enter )
75
-
76
- time .sleep (2 )
74
+ time .sleep (1 )
77
75
78
- get_wordle_evaluation (game_rows [1 ], browser )
76
+ second_string = "trees"
77
+ enter_word (second_string )
78
+ get_row_results (game_rows [1 ])
79
79
80
80
81
81
#From the basic list of words, return all the words with 5 characters.
0 commit comments