File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
code/daniel/lab09-quotes_api Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ # https://favqs.com/api/qotd
2
+
3
+
4
+ #================================
5
+ #Version1
6
+ #================================
7
+
8
+ import requests
9
+
10
+
11
+
12
+ response = requests .get (f"https://favqs.com/api/qotd" , headers = {'Accept' : 'application/json' })
13
+ # print(response)
14
+
15
+
16
+ random_joke = response .json ()
17
+ # print(random_joke)
18
+
19
+
20
+ joke_dict = []
21
+ joke_dict .append (random_joke ['quote' ])
22
+ print ("joke_dict" , joke_dict )
23
+ print ("author" , joke_dict [2 ])
24
+
25
+
26
+ #================================
27
+ #Version2
28
+ #================================
29
+
30
+
31
+ # get_quote = input("Enter a search term to get a random quote: ")
32
+ # print(get_quote)
33
+
34
+
35
+
36
+ # # print(response.text)
37
+ # print("=====================")
38
+ # data = response.json()
39
+ # print("=====================")
40
+ # print(data)
41
+ # print("=====================")
42
+
43
+
44
+
45
+
46
+
47
+
You can’t perform that action at this time.
0 commit comments