Search code examples
pythonredditpraw

subreddits of user using PRAW or R


How to get subreddits of a redditor from PRAW using python or RedditextractoR package in R.

Iam using these comments for sentiment analysis using reddit and need subbreddits a particular user is involved in.

I got comments posts and users using RedditextractoR package in R, But unable to get the information above.


Solution

  • This answer is outdated and no longer working

    This worked for me:

    import praw
    
    user_name = "user_name_to_get"
    user_agent = "subreddit analyzer"
    
    r = praw.Reddit(user_agent=user_agent)
    user = r.get_redditor(user_name)
    
    subs = set()
    
    try:
        overview = user.get_overview()
    
        for item in overview:
            subs.add(item.subreddit.display_name)
    
    except praw.errors.NotFound:
        print("Unable to find user")
    
    print subs