I wrote the following code in python3 which runs perfect:
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
message = ""
run_again = False
try:
    response = requests.get(url, headers=headers, cookies=cookies, allow_redirects=False)
except requests.exceptions.RequestException as e:
    message = "Connection Failed!"
    run_again = True
if "משתמש לא מזוהה" in response.text:
    message = "User Was Logged Out Automatically!"
But when I cut the internet, I get the following error:
    if "משתמש לא מזוהה" in response.text:
UnboundLocalError: local variable 'response' referenced before assignment
how can I solve this?
 
     
     
    