用户使用PRAW或R的子标题

2024-06-14 02:33:20 发布

您现在位置:Python中文网/ 问答频道 /正文

如何使用python或R中的redditor包从PRAW获取redditor的子redditor

Iam使用这些评论进行情绪分析,使用reddit和need子条目来分析特定用户所涉及的内容。在

我有评论帖子和用户使用RedditextractoR包在R,但无法获得上述信息。在


Tags: 用户信息内容评论条目need帖子iam
2条回答

以下是我如何使用PRAW获取我自己用户id的订阅子条目:

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)

这对我很有效:

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

相关问题 更多 >