Created
March 26, 2014 13:22
-
-
Save OdinsHat/9783014 to your computer and use it in GitHub Desktop.
Random Reddit joke from top 20 at r/jokes
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
import praw | |
from random import choice | |
def joke(): | |
"""Prints a joke from a random selection of the | |
top 20 reddit jokes in r/jokes | |
""" | |
r = praw.Reddit(user_agent="Reddit Joke Grabber") | |
subs = r.get_subreddit("jokes").get_hot(limit=20) | |
jokes = list(subs) | |
thejoke = choice(jokes) | |
print("%s\n%s" % (thejoke.title, thejoke.selftext)) | |
if __name__ == "__main__": | |
joke() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment