Created
May 29, 2017 00:58
-
-
Save ishu3101/9c238455857f7c00e895b738d11aabf4 to your computer and use it in GitHub Desktop.
Generate a Random Programming Quote using an API
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/python | |
import urllib | |
import urllib2 | |
import random | |
import json | |
# get a random programming quote using an api | |
url="http://quotes.stormconsultancy.co.uk/random.json" | |
request = urllib2.urlopen(url) | |
data = request.read() | |
print data | |
json = json.loads(data) | |
print json | |
print repr(json) | |
quote = json["quote"] | |
author = json["author"] | |
print quote.encode("utf-8") + " - " + author.encode("utf-8") | |
print quote |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the data does not work on line 13