简体   繁体   English

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

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

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

The only way I can think of doing it is by parsing all his comments and filtering out those comments made on that specific subreddit. 我能想到的唯一方法是解析他的所有评论并过滤掉对该特定subreddit所做的评论。 You can then sort that list based on comment.created_utc and get the oldest comment. 然后,您可以基于comment.created_utc对列表进行排序,并获取最早的评论。

You can parse all the comments of a user and filter comments from a specific subreddit like so - 您可以解析用户的所有评论,并过滤来自特定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