簡體   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