Praw: How to get top posts that were created in last 24 hours?

Question:

I want to get top posts of a subreddit but I only get top posts of all time. How to filter the search results so it only looks for today posts?

My code:

top_memes = subreddit.top(limit=5)

for submission in top_memes:
    print(submission.title)
Asked By: F8te

||

Answers:

The time_filter parameter for .top() accepts one of the following values: all, day, hour, month, week, year.

top_memes = subreddit.top("day", limit=5)

https://praw.readthedocs.io/en/latest/code_overview/models/subreddit.html#praw.models.Subreddit.top

Answered By: Erikp

When PRAW 8 rolls out, you MUST specify `time_filter’.

top_memes = subreddit.top(time_filter="day", limit=5)

https://praw.readthedocs.io/en/latest/code_overview/models/subreddit.html#praw.models.Subreddit.top

Answered By: The3000
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.