使用PRAW或R的用户的subreddits

时间:2016-01-12 21:05:49

标签: python reddit praw

如何使用R中的python或RedditextractoR包从PRAW获取redditor的subreddits。

我使用这些评论来使用reddit进行情绪分析,并且需要特定用户参与subbreddits。

我在R中使用RedditextractoR软件包发表评论帖子和用户,但无法获取上述信息。

2 个答案:

答案 0 :(得分:0)

这对我有用:

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

答案 1 :(得分:0)

这就是我使用PRAW获取自己的用户ID的已订阅子redred的方式:

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)
相关问题