Created
September 27, 2019 02:09
-
-
Save circa10a/7efcbfabd3907293241f2892b3e3d96f to your computer and use it in GitHub Desktop.
fetch json, convert to dict with urlllib
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
#!/usr/bin/env python3 | |
import urllib.request as request | |
import json | |
url = "https://raw.githubusercontent.com/typicode/demo/master/db.json" | |
webURL = request.urlopen(url) | |
data = webURL.read() | |
encoding = webURL.info().get_content_charset('utf-8') | |
JSON_object = json.loads(data.decode(encoding)) | |
print(JSON_object['posts'][0]['title']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment