I wrote this script:
#Defining Functions to use in the script
def make_request(student_id):
"""
Makes a response for the student ID given, Keeps repeating it till it's a successful response.
"""
url = 'http://app1.helwan.edu.eg/Commerce/HasasnUpMlist.asp' #Base URL to our college website
params = {
'z_dep': '=',
'z_st_name': 'LIKE',
'z_st_settingno': '=',
'x_st_settingno': f'{student_id}',
'x_st_name': '',
'z_gro': '=',
'x_gro': '',
'x_dep': '',
'z_sec': 'LIKE',
'x_sec': '',
'Submit': '++++حفظ++++'
}
response = requests.get(url, params=params) #Make a request for the current student
response_state = response.status_code
while response_state != 200 :
response = requests.get(url,params= params)
response_state = response.status_code
return response
I want to adjust it so that it repeats the request if it took more than 10 seconds. I tried doing it with time.time before and after in the body of the while loop but no luck, or maybe I performed it poorly due to limited knowledge of execution order. I'd appreciate your help.