Search code examples
pythonredditpraw

How to get comments from last week using PRAW?


I'm reading the doc for get_comments and I can't figure out what the correct input for the time parameter is. I know the default is "all", but do I input specific dates, or does it have to be words like "day", "week", etc?

Say I want to get comments a user made within the week, would it be something like:

r = praw.Reddit(user_agent='blah')
user = r.get_redditor(username)
comments = user.get_comments(sort='new', time='week', limit=None)

Solution

  • You can see in the source code that the time parameter is passed to the API as t. According to the Reddit API documentation:

    t: one of (hour, day, week, month, year, all)