Created
March 13, 2021 21:36
-
-
Save itsthejoker/33c390748fd8d4184ca81d421b69f9e6 to your computer and use it in GitHub Desktop.
Random dadjoke from fatherhood.gov
This file contains hidden or 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
#!/usr/bin/env python | |
# source: 'https://gist.github.com/itsthejoker/33c390748fd8d4184ca81d421b69f9e6' | |
from urllib import request | |
import json | |
import random | |
resp = request.urlopen("https://fatherhood.gov/jsonapi/node/dad_jokes") | |
joke = random.choice(json.loads(resp.read()).get('data')).get('attributes') | |
if joke: | |
print(joke.get('field_joke_opener')) | |
print(joke.get('field_joke_response')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment