-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefresh_gumtree_offers.py
105 lines (76 loc) · 2.17 KB
/
refresh_gumtree_offers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import pyautogui
import time
number_of_offers_to_refresh = 10
switch_to_gum_tree_tab = False
def switch_window():
if switch_to_gum_tree_tab:
pyautogui.hotkey("alt", "tab")
def open_close_dev_tools():
pyautogui.hotkey("ctrl", "shift", "j")
def clear_dev_tools_console():
pyautogui.hotkey("ctrl", "l")
def open_elements_tab():
open_close_dev_tools()
time.sleep(2)
clear_dev_tools_console()
time.sleep(1)
pyautogui.keyDown("shift")
press_tab_n_times(13)
pyautogui.keyUp("shift")
pyautogui.press("enter")
pyautogui.press("down")
pyautogui.press("enter")
time.sleep(1)
def find_first_instance():
pyautogui.hotkey("ctrl", "f")
pyautogui.write("row clearfix")
def open_all_offers_to_refresh():
for _ in range(number_of_offers_to_refresh):
pyautogui.keyDown("shift")
press_tab_n_times(3)
pyautogui.keyUp("shift")
pyautogui.press("enter")
time.sleep(0.1)
go_to_previous_tab()
press_tab_n_times(3)
pyautogui.press("enter")
time.sleep(2)
def refresh_all_opened_offers():
open_close_dev_tools()
for _ in range(number_of_offers_to_refresh):
go_to_next_tab()
pyautogui.keyDown("shift")
press_tab_n_times(10)
pyautogui.keyUp("shift")
pyautogui.press("enter")
time.sleep(4)
def close_all_refreshed_offers_tabs():
pyautogui.keyDown("ctrl")
for _ in range(number_of_offers_to_refresh):
pyautogui.press("w")
pyautogui.keyUp("ctrl")
def go_to_next_tab():
pyautogui.hotkey("ctrl", "tab")
def go_to_previous_tab():
pyautogui.hotkey("ctrl", "shift", "tab")
def press_tab_n_times(n: int):
for _ in range(n):
pyautogui.press("tab")
def close_tab():
pyautogui.hotkey('ctrl', 'w')
def refresh_tab():
pyautogui.press("f5")
if __name__ == '__main__':
for i in range(3, 0, -1):
print(i)
time.sleep(0.5)
print("Start!")
time.sleep(1)
switch_window()
open_elements_tab()
find_first_instance()
open_all_offers_to_refresh()
refresh_all_opened_offers()
close_all_refreshed_offers_tabs()
pyautogui.press("home")
refresh_tab()