How to get top posts of year 2022 in reddit using psaw/praw python?

Viewed 20

I am trying to get top 100 posts(top posts meaning one's which have high upvotes) of year 2022 from a subreddit using praw/psaw .

I used following code:

api = PushshiftAPI(reddit) # using psaw
start_epoch=int(dt.datetime(2022, 1, 1).timestamp()) # date of 01/01/2022
submissions_generator = api.search_submissions(after=start_epoch, subreddit='datascience')

or

submissions = reddit.subreddit('learnpython').top(limit=100) #praw
#This one doesnt have time filter to get only for year 2022

But the first code provides only recent posts in the subreddit. Is there a way to get top 100 posts of a subreddit of year 2022?

0 Answers
Related