Python’s Requests Library (Guide) – Real Python
realpython.com › python-requestsimport requests from requests.adapters import HTTPAdapter from requests.exceptions import ConnectionError github_adapter = HTTPAdapter (max_retries = 3) session = requests. Session () # Use `github_adapter` for all requests to endpoints that start with this URL session . mount ( 'https://api.github.com' , github_adapter ) try : session . get ( 'https://api.github.com' ) except ConnectionError as ce : print ( ce )