psf / requests

A simple, yet elegant, HTTP library.
https://requests.readthedocs.io/en/latest/
Apache License 2.0
52.19k stars 9.33k forks source link

Doc: missing example #6782

Open nixilb opened 3 months ago

nixilb commented 3 months ago

Looking at quickstart: a copy paste example that just works with status error magagement, is missing.

nateprewitt commented 3 months ago

Hi @nixilb, could you be more specific with what you're looking for? We have a section in the Quickstart guide about this topic already.

nixilb commented 3 months ago

some COMPLETE code one can copy paste and works

like (found in https://realpython.com/python-requests/)

import requests
from requests.exceptions import HTTPError

try:
    response = requests.get("https://api.github.com")
    response.raise_for_status()
    print(response.text)
except HTTPError as http_err:
    print(f"HTTP error occurred: {http_err}")
except Exception as err:
    print(f"Other error occurred: {err}")
else:
    print("Success!")