Skip to content

Instantly share code, notes, and snippets.

@constrict0r
Last active July 25, 2019 21:55
Show Gist options
  • Save constrict0r/cec36bc93db35f7bec0dd26ee1ec417f to your computer and use it in GitHub Desktop.
Save constrict0r/cec36bc93db35f7bec0dd26ee1ec417f to your computer and use it in GitHub Desktop.
Multiple ways to check if an URL is alive.
# Using requests.
import request
request = requests.get(value)
if request.status_code == 200:
return True
return False
# Using httplib2.
import httplib2
try:
http = httplib2.Http()
response = http.request(value, 'HEAD')
if int(response[0]['status']) == 200:
return True
except:
pass
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment