@@ -78,9 +78,9 @@ def reserve_restaurant(page, selected_reservation):
78
78
return 2
79
79
80
80
def print_list_bookings (listbookings ):
81
- print ("List of Bookings:" )
81
+ # print("List of Bookings:")
82
82
for idx , lb in enumerate (listbookings ):
83
- print (f" { idx + 1 } . " , "Restaurant Name:" , str (lb ['baseurl' ]).split ("/" )[- 1 ], "| Period:" , lb ['period' ], "| Date:" , lb ['date' ], "| Time:" , lb ['time' ], "| Seats:" , lb ['seats' ] )
83
+ print ("*** " , "Restaurant Name:" , str (lb ['baseurl' ]).split ("/" )[- 1 ], "| Period:" , lb ['period' ], "| Date:" , lb ['date' ], "| Time:" , lb ['time' ], "| Seats:" , lb ['seats' ], "***" )
84
84
85
85
def main ():
86
86
parser = argparse .ArgumentParser (description = "Resy Bot v3b" )
@@ -94,10 +94,11 @@ def main():
94
94
parser .add_argument ('-em' , '--email' , type = str ,help = "Resy Email" )
95
95
parser .add_argument ('-pw' , '--password' , type = str ,help = "Resy Password" )
96
96
parser .add_argument ('-hl' , '--headless' , type = str ,help = "Headless Mode" )
97
+ parser .add_argument ('-ns' , '--nonstop' , type = str ,help = "Nonstop Checking Mode" )
97
98
args = parser .parse_args ()
98
99
99
- if not args .url or not args .date or not args .time or not args .seats or not args .period or not args .reservation or not args .chprofile or not args .email or not args .password or not args .headless :
100
- input (" " .join (['Please add complete parameters, ex: python resybotv3 -u [url] -d [dd-mm-yyyy] -t [h:m am/pm] -s [seats_count] -p [period] -r [reservation_type] -cp [chrome_profile] -em [email] -pw [password] -hl [headless]' , CLOSE_MESSAGE ]))
100
+ if not args .url or not args .date or not args .time or not args .seats or not args .period or not args .reservation or not args .chprofile or not args .email or not args .password or not args .headless or not args . nonstop :
101
+ input (" " .join (['Please add complete parameters, ex: python resybotv3 -u [url] -d [dd-mm-yyyy] -t [h:m am/pm] -s [seats_count] -p [period] -r [reservation_type] -cp [chrome_profile] -em [email] -pw [password] -hl [headless] -ns [nonstop] ' , CLOSE_MESSAGE ]))
101
102
sys .exit ()
102
103
103
104
date_wanted = args .date
@@ -111,6 +112,10 @@ def main():
111
112
password = args .password
112
113
headless = args .headless
113
114
headless = True if headless == 'Yes' else False
115
+ nonstop = args .nonstop
116
+ nonstop = True if nonstop == 'Yes' else False
117
+ commandlist = [{"baseurl" : args .url , "date" : date_wanted , "period" :period_wanted , "time" : time_wanted , "seats" : seats , "reservation_type" : reservation_type , "status" : False }]
118
+ print_list_bookings (commandlist )
114
119
115
120
user_agents = [
116
121
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" ,
@@ -120,66 +125,67 @@ def main():
120
125
# More user agents can be added here
121
126
]
122
127
chrome_user_data = f"{ CHROME_USER_DATA } \\ { chprofile } "
123
- try :
124
- user_agent = random . choice ( user_agents )
125
- with sync_playwright () as pr :
126
- wargs = []
127
- # wargs.append('--enable-logging=stderr')
128
- # list chromium arguments: https://peter.sh/experiments/chromium-command-line-switches/
129
- wargs .append ('--v=1 ' )
130
- wargs .append ('--no-sandbox ' )
131
- wargs .append ('--enable-features=NetworkService,NetworkServiceInProcess ' )
132
- wargs .append ('--enable-automation ' )
133
- wargs .append ('--disable-popup-blocking ' )
134
- wargs .append ('--disable-web-security ' )
135
- wargs . append ( '--start-maximized' )
136
-
137
- wargs .append ('--disable-fetching-hints-at-navigation-start ' )
138
- wargs .append ('--force-first-run ' )
139
- wargs .append ('--content-shell-hide-toolbar ' )
140
- wargs .append ('--suppress-message-center-popups ' )
141
- wargs .append ('--no-first-run ' )
142
- wargs . append ( '--force-show-update-menu-badge' )
143
-
144
-
145
- browser = pr . chromium . launch ( headless = headless , args = wargs )
146
- # breakpoint()
147
- proxy_server = "http://kpeqkzlp:[email protected] :5868"
148
- context = browser . new_context (
149
- user_agent = user_agent ,
150
- no_viewport = True ,
151
- permissions = [ 'geolocation' , 'notifications' ] ,
152
- java_script_enabled = True ,
153
- #proxy = {
154
- #'server': proxy_server
155
- #}
156
- )
157
-
158
- # def slow_down_route(route, request):
159
- # # Slow down network request by 2000 milliseconds.
160
- # route.continue_()
161
- # browser.route('**', slow_down_route)
162
-
163
- page = context . new_page ( )
164
- stealth_sync ( page )
165
-
166
- page .on ("console " , lambda msg : logging .debug (f"PAGE LOG : { msg . text } " ))
167
- page .on ("pageerror " , lambda msg : logging .error (f"PAGE ERROR : { msg } " ))
168
- page .on ("response " , lambda response : logging .debug (f"RESPONSE : { response .url } { response . status } " ))
169
- page . on ( "requestfailed" , lambda request : logging . error ( f"REQUEST FAILED: { request . url } { request . failure } " ))
170
-
171
- login = False
172
- print ( "" )
173
- message = f"Bot is running... [ { chprofile } ]"
174
- logging . info (message )
175
- print ( message )
176
- maxtrial = 5
177
- trial = 0
178
- status = False
179
- while not status :
128
+ user_agent = random . choice ( user_agents )
129
+ with sync_playwright () as pr :
130
+ wargs = []
131
+ # wargs.append('--enable-logging=stderr')
132
+ # list chromium arguments: https://peter.sh/experiments/chromium-command-line-switches/
133
+ wargs . append ( '--v=1' )
134
+ wargs .append ('--no-sandbox ' )
135
+ wargs .append ('--enable-features=NetworkService,NetworkServiceInProcess ' )
136
+ wargs .append ('--enable-automation ' )
137
+ wargs .append ('--disable-popup-blocking ' )
138
+ wargs .append ('--disable-web-security ' )
139
+ wargs .append ('--start-maximized ' )
140
+
141
+ wargs . append ( '--disable-fetching-hints-at-navigation-start' )
142
+ wargs .append ('--force-first-run ' )
143
+ wargs .append ('--content-shell-hide-toolbar ' )
144
+ wargs .append ('--suppress-message-center-popups ' )
145
+ wargs .append ('--no-first-run ' )
146
+ wargs .append ('--force-show-update-menu-badge ' )
147
+
148
+
149
+ browser = pr . chromium . launch ( headless = headless , args = wargs )
150
+ # breakpoint( )
151
+ proxy_server = "http://kpeqkzlp:[email protected] :5868"
152
+ context = browser . new_context (
153
+ user_agent = user_agent ,
154
+ no_viewport = True ,
155
+ permissions = [ 'geolocation' , 'notifications' ] ,
156
+ java_script_enabled = True ,
157
+ #proxy = {
158
+ #'server': proxy_server
159
+ #}
160
+ )
161
+
162
+ # def slow_down_route(route, request):
163
+ # # Slow down network request by 2000 milliseconds.
164
+ # route.continue_()
165
+ # browser.route('**', slow_down_route)
166
+
167
+ page = context . new_page ()
168
+ stealth_sync ( page )
169
+
170
+ page . on ( "console" , lambda msg : logging . debug ( f"PAGE LOG: { msg . text } " ))
171
+ page .on ("pageerror " , lambda msg : logging .error (f"PAGE ERROR : { msg } " ))
172
+ page .on ("response " , lambda response : logging .debug (f"RESPONSE : { response . url } { response . status } " ))
173
+ page .on ("requestfailed " , lambda request : logging .error (f"REQUEST FAILED : { request .url } { request . failure } " ))
174
+
175
+ login = False
176
+ print ( "" )
177
+ message = f"Bot is running... [ { chprofile } ]"
178
+ logging . info ( message )
179
+ print (message )
180
+ maxtrial = 3
181
+ trial = 0
182
+ status = False
183
+ while not status :
184
+ try :
180
185
random_delay (3 , 6 )
181
- if trial >= maxtrial :
182
- break
186
+ if not nonstop :
187
+ if trial >= maxtrial :
188
+ break
183
189
trial += 1
184
190
print (f"Trying going to { restaurant_link } ..." , end = " " , flush = True )
185
191
page .goto (restaurant_link , wait_until = 'domcontentloaded' )
@@ -234,18 +240,13 @@ def main():
234
240
logging .info (message )
235
241
print (" " .join ([message , CONTINUE_MESSAGE ]))
236
242
continue
237
- # sys.exit()
238
-
239
243
240
- # break
241
- except Exception as e :
242
- # Show all error details in log file
243
- message = "An error occurred"
244
- print (message , e )
245
- logging .exception (message )
246
- # sys.exit()
247
- # continue
248
- # return e
244
+ except Exception as e :
245
+ message = "An error occurred"
246
+ print (message , e )
247
+ logging .exception (message )
248
+ continue
249
+
249
250
250
251
251
252
if __name__ == '__main__' :
0 commit comments