Random Jokes Generator
- Python API
Laugh. Or not :b
# Import the relevant modules
import requests
import json
# The documentation for this particular API can be found here:
# https://github.com/15Dkatz/official_joke_api
# define base URL
base_site = "https://official-joke-api.appspot.com/random_joke"
# To see 5 random jokes
for i in range(5):
# Make a request
r = requests.get(base_site)
r.status_code
if(r.ok is False):
print("\nError {}:".format(r.status_code))
#print(r.json()['error'])
else:
# Store the response
info = r.json()
# Cycle through the results
print(info['setup'])
print(info['punchline'])
print("")
Which song would an exception sing?
Can't catch me - Avicii
I can't tell if i like this blender...
It keeps giving me mixed results.
A termite walks into a bar and says...
'Where is the bar tended?'
What is the difference between ignorance and apathy?
I don't know and I don't care.
What time did the man go to the dentist?
Tooth hurt-y.