Python 3 Get and parse JSON API [duplicate]

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)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)