File tree Expand file tree Collapse file tree 3 files changed +101
-0
lines changed Expand file tree Collapse file tree 3 files changed +101
-0
lines changed Original file line number Diff line number Diff line change
1
+ '''
2
+ Justin Young
3
+ Lab 08
4
+ Version1
5
+ '''
6
+
7
+ import requests
8
+ import time
9
+
10
+ response = requests .get ("https://icanhazdadjoke.com" , headers = {'Accept' : 'application/json' })
11
+ call = response .json ()
12
+ x = input ('wanna hear a joke? y/n: ' )
13
+ if x == 'y' :
14
+ print (call ['joke' ])
15
+
16
+
Original file line number Diff line number Diff line change
1
+ '''
2
+ Justin Young
3
+ Lab 08
4
+ Version2
5
+ '''
6
+
7
+ import requests
8
+ import time
9
+
10
+
11
+ u_input = input ('enter a search term: ' )
12
+ response = requests .get (f"https://icanhazdadjoke.com/search?term=${ u_input } " , headers = {
13
+ 'Accept' : 'application/json'
14
+ })
15
+
16
+ js = response .json ()
17
+ total = js ['total_jokes' ]
18
+ for j in js ['results' ]:
19
+ print (f'\n There are { total } more jokes with the word { u_input } , get ready for the next one!!' )
20
+ total -= 1
21
+ time .sleep (3 )
22
+ print ('\n ----------------------------------------------------------------------' )
23
+ print (j ['joke' ])
24
+ print ('----------------------------------------------------------------------' )
25
+ if total == 0 :
26
+ print (f'Thats all the jokes with { u_input } , thanks!' )
27
+ break
28
+ a = input (f'\n LOL! Funny right? another joke? y/n: ' )
29
+ if a .lower () == 'n' :
30
+ break
31
+
Original file line number Diff line number Diff line change
1
+ # import requests
2
+
3
+ # response = requests.get('https://google.com')
4
+ # # print(response)
5
+ # # print(type(response))
6
+ # # print(response.text)
7
+ # print(response.status_code)
8
+
9
+ # response = requests.get('https://api.chucknorris.io/jokes/random')
10
+
11
+ # print(response)
12
+ # print(response.text)
13
+
14
+ # joke = response.text
15
+ # joke = response.json() #python friendly dictionary0--------
16
+ # # print(joke)
17
+ # # print(joke['value'])
18
+
19
+
20
+ # response = requests.get('https://api.chucknorris.io/jokes/categories')
21
+ # # print(response.json())
22
+
23
+ # categories = response.json()
24
+
25
+ # # for category in categories:
26
+ # # print(category)
27
+
28
+ # for i in range(len(categories)):
29
+ # print(i, categories[i])
30
+
31
+ # choice = int(input('Select a category: '))
32
+
33
+ # query = {
34
+ # 'category' : categories[choice]
35
+ # }
36
+
37
+ # # response = requests.get(f'https://api.chucknorris.io/jokes/random?category={categories[choice]}')
38
+ # response = requests.get('https://api.chucknorris.io/jokes/random', params=query)
39
+
40
+ # print(response.text)
41
+
42
+ import requests
43
+ url = 'https://ghibliapi.herokuapp.com/films'
44
+ response = requests .get (url )
45
+ print (response )
46
+ # print(response.text)
47
+ print (response .json ())
48
+ data = response .json ()
49
+ # print(data[0]['title'])
50
+ # for film in data:
51
+ # print(film['title'])
52
+ # print(film['release_date'])
53
+ # print(film['description'])
54
+ # print('-'*10)
You can’t perform that action at this time.
0 commit comments