Just wanted to share a quick snippet on how to fetch data using an HTTP GET request in Python. It's super straightforward with the requests library.
- import requests
- #URL to read from
- url = "YOUR_URL_HERE" #Replace with your actual URL
- #Send a GET request
- response = requests.get(url)
- #Check the response status
- if response.status_code == 200:
- #Success! Print the content
- print(response.text)
- else:
- #Something went wrong
- print(f"Failed to retrieve data: {response.status_code}")
Remember to replace "YOUR_URL_HERE" with the actual URL you want to access! Hope this helps!