I’m looking for a quick way to get an HTTP response code from a URL (i.e. 200, 404, etc). I’m not sure which library to use.
Update using the wonderful requests library. Note we are using the HEAD request, which should happen more quickly then a full GET or POST request.
import requests try: r = requests.head("https://stackoverflow.com") print(r.status_code) # prints the int of the status code. Find more at httpstatusrappers.com :) except requests.ConnectionError: print("failed to connect")
1.4m articles
1.4m replys
5 comments
57.0k users