pypihttp95% confidence\u2191 105

Get HTTP Error code from requests.exceptions.HTTPError

Full error message
I am catching exceptions like this,

def get_url_fp(image_url, request_kwargs=None):
    response = requests.get(some_url, **request_kwargs)
    response.raise_for_status()
    return response.raw

try:
   a = "http://example.com"
   fp = get_url_fp(a)

except HTTPError as e:
    # Need to check its an 404, 503, 500, 403 etc.

The HTTPError carries the Response object with it: def get_url_fp(image_url, request_kwargs=None): response = requests.get(some_url, **request_kwargs) response.raise_for_status() return response.raw try: a = "http://example.com" fp = get_url_fp(a) except HTTPError as e: # Need to check its an 404, 503, 500, 403 etc. status_code = e.response.status_code

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/a26995551242b89ce62148827bd12db96965384f6f43a3095f87e63ba71c3cc7
hash \u00b7 a26995551242b89ce62148827bd12db96965384f6f43a3095f87e63ba71c3cc7
Get HTTP Error code from requests.exceptions.HTTPError — DepScope fix | DepScope