Look at the r.status_code attribute: if r.status_code == 404: # A 404 was issued. e.g.: >>> import requests >>> r = requests.get('http://httpbin.org/status/404') >>> r.status_code 404