Skip to main content
100%

Example of GET request in Python

✓ Published0🌍 Public
EEleonore9
Last edited Jan 26, 2016
Created on Jan 26, 2016

This example demonstrates how to perform a basic GET request in Python, handling authentication and potential errors gracefully. It uses the `requests` library with `HTTPBasicAuth` to send a request to a specified URL, then checks the response status and returns the JSON data if successful. The code also catches various exceptions from `requests.exceptions`—including connection errors, timeouts, and HTTP errors—to report failure messages. The visible structure shows an import of `urlparse` and `sys`, though no URL parsing or system exit is actively used beyond the final error handling.

AI-generated description

Similar vizzes