For a small script i have to test if a server i'm trying to download a file from is available to prevent errors. I Tried pinging the server (school website), but pinging is not allowed so i wouldn't get any responses. I could try pinging google.com, but this only checks the client side of the connection. pinging also doesn't work when i'm at school because of the same reason.
Code i am using now:
import subprocess
try:
subprocess.check_output(["ping", "-n", "1", "-w", "1000", "google.com"])
except subprocess.CalledProcessError:
# Code to run when no internet connection is available
return False
I was wondering if there's another way to check server availability without using ping, but by still using python. For the solutions I was able to find only i couldn't find a way to implement it in python (by my experience)