How would I parse a json api response with python? I currently have this:
import urllib.request
import json
url = \'https://hacker-news.firebaseio.com/v0/topsto
Version 1: (do a pip install requests
before running the script)
import requests
r = requests.get(url='https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty')
print(r.json())
Version 2: (do a pip install wget
before running the script)
import wget
fs = wget.download(url='https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty')
with open(fs, 'r') as f:
content = f.read()
print(content)