@@ -50,6 +50,8 @@ def tab_overview_setup():
50
50
def bet_overview_static_text ():
51
51
Label (bet_overview , text = "Betfair Sportsbook URL: " ).grid (row = 1 , column = 1 , columnspan = 1 )
52
52
Label (bet_overview , text = "Strategy: " ).grid (row = 2 , column = 1 , columnspan = 1 )
53
+ Label (bet_overview , text = "TIme period (s): " ).grid (row = 3 , column = 1 , columnspan = 1 )
54
+
53
55
bet_overview_static_text () # call static text
54
56
55
57
# & Bet URL input
@@ -58,6 +60,8 @@ def bet_overview_static_text():
58
60
bet_url_entry .grid (row = rw ,column = 3 , columnspan = 7 , sticky = "W" )
59
61
bet_url_entry .insert (END ,"https://www.betfair.com/exchange/plus/football" )
60
62
63
+
64
+ # Strategy drop down menu
61
65
OPTIONS = []
62
66
import os
63
67
for file in os .listdir ():
@@ -71,6 +75,17 @@ def bet_overview_static_text():
71
75
72
76
w = OptionMenu (bet_overview , strategyoptions , * OPTIONS )
73
77
w .grid (row = 2 , column = 3 , columnspan = 1 )
78
+
79
+ # Timer drop down menu
80
+ timeoptions = [60 ,600 ,6000 ,6000 ]
81
+
82
+ global timeoption
83
+ timeoption = StringVar (bet_overview )
84
+ timeoption .set (timeoptions [3 ]) # default value
85
+
86
+ w = OptionMenu (bet_overview , timeoption , * timeoptions )
87
+ w .grid (row = 3 , column = 3 , columnspan = 1 )
88
+
74
89
#w.pack()
75
90
76
91
@@ -217,7 +232,7 @@ def scrape_url(self):
217
232
# ACTION: Retrieve URL from Tkinter text window
218
233
url = bet_url_entry .get ()
219
234
strategy = strategyoptions .get ()
220
-
235
+ timelimit = int ( timeoption . get ())
221
236
# ACTION: Open Driver window and define driver variable
222
237
try :
223
238
# COMMENT: Case where we have already opened the window
@@ -227,9 +242,12 @@ def scrape_url(self):
227
242
url_previous = "not available"
228
243
opened_driver = get_driver (url ,url_previous )
229
244
245
+ print ("Macro started" )
230
246
231
247
# ACTION: Loop through calls of functions
232
- for n in range (0 ,100000 ):
248
+ time_elapsed = 0
249
+ start_time = time .time ()
250
+ while time_elapsed <= timelimit :
233
251
234
252
# STEP: Connect to database
235
253
conn = sqlite3 .connect ('bet_data.db' )
@@ -280,17 +298,15 @@ def scrape_url(self):
280
298
break
281
299
282
300
# COMMENT: print function provides feedback to user that loop is running
283
- print (n )
284
301
285
302
# STEP: Close the database connection
286
303
conn .close ()
287
304
288
- # STEP: refresh the driver to ensure we get the latest betting data
289
- #opened_driver.driver.refresh()
290
-
291
- # STEP: sleep for 1 second to allow the refreshed driver to open
292
- #time.sleep(0.5)
293
-
305
+ # STEP: Increment time elapsed
306
+ time_elapsed = time .time () - start_time
307
+ print (str (time_elapsed )+ "s - cycle completed" )
308
+
309
+ print ("Macro finished" )
294
310
295
311
# ============= Tidy up ============
296
312
# COMMENT: define url_previous to allow the existing driver to be used again
0 commit comments