forked from sourabhjagtap95/AwesomePythonScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquote.py
More file actions
24 lines (20 loc) · 606 Bytes
/
Copy pathquote.py
File metadata and controls
24 lines (20 loc) · 606 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json
import sys
try:
import urllib.request
request = urllib.request.urlopen
except ImportError:
import urllib2
request = urllib2.urlopen
def getQuote():
json_data = request("https://talaikis.com/api/quotes/random/")
quote_data = json.load(json_data)
quote = quote_data["quote"]
author = quote_data["author"]
return quote, author
if __name__ == "__main__":
quote, author = getQuote()
quote = "\033[1;36m" + "\"" + quote + "\"" + "\033[1;m"
author = "\033[1;35m" + "--" + author + "\033[1;m"
output = quote + "\n\t\t" + author
print(output)