Search code examples
pythonredditpraw

How to get only top/most_recent 5 submissions of user in reddit using PRAW


As mentioned in the docs,

    for submission in reddit.redditor('spez').submissions.top('all'):
        print(submission.title)

returns top 100 submissions for user 'spez'.

How do I limit this to 10 submissions ?


Solution

  • Looking at the documentation, there should be optional arguments you can put in your call to top. One of these is limit which will limit the number of entries it fetches.

    Try,

    for submission in reddit.redditor('spez').submissions.top('all', limit=10):
        print(submission.title)