你能用PRAW在subreddit中找到某人的第一个评论吗?

问题描述 投票:0回答:1

看起来没有办法通过PRAW获得用户订阅subreddit的日期,但是有没有办法在特定的subreddit中获得用户的第一条评论?

python reddit praw
1个回答
1
投票

我能想到的唯一方法就是解析他的所有评论并过滤掉那些特定subreddit上的评论。然后,您可以根据comment.created_utc对该列表进行排序,并获取最早的评论。

您可以解析用户的所有注释并过滤来自特定subreddit的注释,如下所示 -

user = reddit.redditor('username')
target_subreddit = 'target_subreddit'
comment_list = []
# This iterates over all the comments made by the user
for comment in user.comments.new(limit=None):
    # Check if a comment belongs to your target subreddit
    if str(comment.subreddit) == target_subreddit:
        comment_list.append(comment)

# Sort comment_list based on comment.created_utc to get the oldest comment
...
© www.soinside.com 2019 - 2024. All rights reserved.