What I'm aiming to do is to get the top submission from Reddit, append it to an array and then get the second top submission, third, fourth, etc. I'm using place_holder to get the next submission, which works the first time but then just loops through getting the same, second, submission over and over again.
The current output is
Post 1
Post 2
Post 2
etc
When I want the output to be
Post 1
Post 2
Post 3
Post 4
etc
Here's my code:
import praw, time
r = praw.Reddit(user_agent='ADNPost')
already_done = []
while True:
for submission in r.get_top(limit=1):
id = submission.id
title = submission.title
url = submission.short_link
save_state = (id)
if id not in already_done:
already_done.append(submission.id)
post = title + " | " + url
print post
print save_state
if id in already_done:
for submission in r.get_front_page(limit=1, place_holder=submission.id):
id = submission.id
title = submission.title
url = submission.short_link
print title, url
save_state = (id)
already_done.append(submission.id)
time.sleep(2)