Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions code/justin/lab08_version1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'''
Justin Young
Lab 08
Version1
'''

import requests
import time

response = requests.get("https://icanhazdadjoke.com", headers={'Accept': 'application/json'})
call = response.json()
x = input('wanna hear a joke? y/n: ')
if x == 'y':
print(call['joke'])


31 changes: 31 additions & 0 deletions code/justin/lab08_version2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'''
Justin Young
Lab 08
Version2
'''

import requests
import time


u_input = input('enter a search term: ')
response = requests.get(f"https://icanhazdadjoke.com/search?term=${u_input}", headers={
'Accept': 'application/json'
})

js = response.json()
total = js['total_jokes']
for j in js['results']:
print(f'\nThere are {total} more jokes with the word {u_input}, get ready for the next one!!')
total -= 1
time.sleep(3)
print('\n----------------------------------------------------------------------')
print(j['joke'])
print('----------------------------------------------------------------------')
if total == 0:
print(f'Thats all the jokes with {u_input}, thanks!')
break
a = input(f'\nLOL! Funny right? another joke? y/n: ')
if a.lower() == 'n':
break

54 changes: 54 additions & 0 deletions code/justin/requests_lecture_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# import requests

# response = requests.get('https://google.com')
# # print(response)
# # print(type(response))
# # print(response.text)
# print(response.status_code)

# response = requests.get('https://api.chucknorris.io/jokes/random')

# print(response)
# print(response.text)

# joke = response.text
# joke = response.json() #python friendly dictionary0--------
# # print(joke)
# # print(joke['value'])


# response = requests.get('https://api.chucknorris.io/jokes/categories')
# # print(response.json())

# categories = response.json()

# # for category in categories:
# # print(category)

# for i in range(len(categories)):
# print(i, categories[i])

# choice = int(input('Select a category: '))

# query = {
# 'category' : categories[choice]
# }

# # response = requests.get(f'https://api.chucknorris.io/jokes/random?category={categories[choice]}')
# response = requests.get('https://api.chucknorris.io/jokes/random', params=query)

# print(response.text)

import requests
url = 'https://ghibliapi.herokuapp.com/films'
response = requests.get(url)
print(response)
# print(response.text)
print(response.json())
data = response.json()
# print(data[0]['title'])
# for film in data:
# print(film['title'])
# print(film['release_date'])
# print(film['description'])
# print('-'*10)