繁体   English   中英

您可以使用PRAW在subreddit中找到某人的第一条评论吗?

[英]Can you use PRAW to find someone's first comment in a subreddit?

似乎无法获取用户通过PRAW订阅subreddit的日期,但是是否可以获取用户在特定subreddit中的第一条评论?

我能想到的唯一方法是解析他的所有评论并过滤掉对该特定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
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM