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.
Addressing @Niklas R's comment to @nickanor's answer:
from urllib.error import HTTPError import urllib.request def getResponseCode(url): try: conn = urllib.request.urlopen(url) return conn.getcode() except HTTPError as e: return e.code