Reputation: 33
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.
Upvotes: 3
Views: 1607
Reputation: 4354
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
Upvotes: -1
Reputation: 4527
This is how I fetched the subscribed subreddits of my own user-id using PRAW :
reddit = praw.Reddit(client_id='client-id',
client_secret="client-secret",
username='username',
password='password',
user_agent='agent')
subredditList = reddit.user.subreddits(limit=None)
for item in subredditList:
print(item.display_name)
Upvotes: 2