Created
October 2, 2017 16:04
-
-
Save jonallured/a637d01b937f74af7a40a961f571c7fe to your computer and use it in GitHub Desktop.
This file contains 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
import urllib.request, json | |
def lambda_handler(_event, _context): | |
with urllib.request.urlopen("https://daringfireball.net/feeds/json") as url: | |
data = json.loads(url.read().decode()) | |
keys = ["id", "url", "title", "date_published"] | |
items = data["items"] | |
new_items = [] | |
for item in items: | |
new_item = { key: item[key] for key in keys } | |
new_items.append(new_item) | |
feed = { | |
"version" : "https://jsonfeed.org/version/1", | |
"title" : "Daring Fireball", | |
"items" : new_items | |
} | |
return json.dumps(feed) | |
print(lambda_handler([], 0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment