1Raise an exception if a request is unsuccessful
2
3import requests
4url = "http://mock.kite.com/status/404"
5r = requests.get(url)
6try:
7 r.raise_for_status()
8except requests.exceptions.HTTPError as e:
9 print e
10OUTPUT
11404 Client Error: NOT FOUND