Last active
April 17, 2022 08:09
-
-
Save IT102Gists/2c142ed70286b0ad948c0924796e6fb0 to your computer and use it in GitHub Desktop.
Fetch a random joke from the Internet Chuck Norris Database (ICNDb) with Python 3 and Requests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Learn more about the ICNDb API at: http://www.icndb.com/api/ | |
# Learn more about the Requests library at: http://docs.python-requests.org/en/master/ | |
import requests | |
def get_joke(): | |
"""fetches and prints a random joke""" | |
url = "http://api.icndb.com/jokes/random" | |
resp = requests.get(url) | |
data = resp.json() | |
print(data["value"]["joke"]) | |
get_joke() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment