-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet_jokes.py
32 lines (26 loc) · 870 Bytes
/
Get_jokes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#Imports
import praw
import random
#Providing the ecessary info
reddit = praw.Reddit(client_id = "Client_ID",
client_secret = "CLIENT_SECRET",
username = "USERNAME_ON_REDDIT",
password = "PASSWORD_OF_PROFILE",
user_agent = "pythonpraw")
#The code
jokes = []
subreddit = reddit.subreddit("jokes")
top = subreddit.top(limit = 100)
all_submissions = []
for submission in top:
all_submissions.append(submission)
rand_sub = random.choice(all_submissions)
rand_sub_title = rand_sub.title
rand_sub_text = rand_sub.selftext
rand_sub_url = rand_sub.url
upvotes = rand_sub.score
if not submission.over_18:
print("TITLE: " + rand_sub_title)
print("Joke: " + rand_sub_text)
print("URL: " + rand_sub_url)
print("Upvotes: " + str(upvotes))