Skip to content

Instantly share code, notes, and snippets.

@jonallured
Created October 2, 2017 16:04
Show Gist options
  • Save jonallured/a637d01b937f74af7a40a961f571c7fe to your computer and use it in GitHub Desktop.
Save jonallured/a637d01b937f74af7a40a961f571c7fe to your computer and use it in GitHub Desktop.
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