Search code examples
pythonpraw

How to get a user object in Praw?


I'm attempting to find the user of Reddit so I can iterate through their last comments, weird reason but I'm in need of getting the user's object.

Cannot find in the docs where there's a way to get a user via username.


Solution

  • import praw 
    
    reddit = praw.Reddit(client_id='xxxxxxxxx',
                         client_secret='xxxxxxxx', 
                         password='xxxxxxxxx',
                         user_agent='xxxxxxx',
                         username='xxxxxxxx')
    
    user = reddit.redditor('username')
    

    https://praw.readthedocs.io/en/latest/code_overview/models/redditor.html