Skip to content

Instantly share code, notes, and snippets.

@niekvandepas
Last active August 29, 2015 14:18
Show Gist options
  • Save niekvandepas/52ae5966ed4014540e67 to your computer and use it in GitHub Desktop.
Save niekvandepas/52ae5966ed4014540e67 to your computer and use it in GitHub Desktop.
# Script that finds submissions in earthporn.reddit.com with more than 1000 points and prints them.
# Used for a personal project.
import time
import praw
# Connecting to Reddit and setting user agent
r = praw.Reddit('r/earthporn monitor by u/niek_pas')
# Getting subreddit and storing in variable 'subreddit'
subreddit = r.get_subreddit('earthporn')
# Declaring list of already added submissions to ensure no duplicates
already_done = []
# Declaring and opening output file
output_file = open("Output.txt", "a")
# The script will check if the 10 'hottest' submissions have more than 1000 upvotes and haven't
# been added yet. If this is true, the submission score, title, and shortlink are written to the file output_file.
# Then sleep for half an hour and check again.
while True:
for submission in subreddit.get_hot(limit=10):
if submission.id not in already_done and submission.score >= 1000:
output_file.write(str(submission.score) + ' -- ' + submission.title + ' -- ' + submission.short_link + '\n')
already_done.append(submission.id)
time.sleep(1800)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment