File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ Packages Used
2+
3+ ```
4+ pip install requests
5+ ```
6+
7+ API used : Quote Garden
Original file line number Diff line number Diff line change 1+ import requests
2+
3+
4+ ## function that gets the random quote
5+ def get_random_quote ():
6+ try :
7+ ## making the get request
8+ response = requests .get ("https://quote-garden.herokuapp.com/api/v3/quotes/random" )
9+ if response .status_code == 200 :
10+ ## extracting the core data
11+ json_data = response .json ()
12+ data = json_data ['data' ]
13+
14+ ## getting the quote from the data
15+ print (data [0 ]['quoteText' ])
16+ else :
17+ print ("Error while getting quote" )
18+ except :
19+ print ("Something went wrong! Try Again!" )
20+
21+
22+ get_random_quote ()
You can’t perform that action at this time.
0 commit comments