Created
February 26, 2026 11:41
-
-
Save zeshanshani/613ef8e6e45275780b7a0d5954eb159a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Retrieve a single article and its image with requests | |
| import requests | |
| BASE = "https://web-news-service.greenstreet.com" | |
| def get_article(token, article_id): | |
| r = requests.get(f"{BASE}/api/articles/{article_id}", headers={"Authorization": f"Bearer {token}"}) | |
| r.raise_for_status() | |
| return r.json() | |
| def get_featured_image(token, article_id, src, region): | |
| r = requests.get( | |
| f"{BASE}/api/articles/{article_id}/image", | |
| headers={"Authorization": f"Bearer {token}"}, | |
| params={"src": src, "region": region}, | |
| ) | |
| r.raise_for_status() | |
| return r.content # binary image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment