Python Reddit API:提取两个给定时间戳之间的用户评论

Python Reddit API: Extracting User Comments Between Two Given Timestamps

PRAW 允许在两个时间戳之间的给定 subreddit 上提取 submissionsreddit.subreddit('news').submissions(startStamp, endStamp)

但是,我还没有找到任何类似的方法来提取两个时间戳之间给定用户的评论。这可以做到吗?我实际上并不关心 1000 个请求的限制,除非我得到的评论属于正确的时间范围。我已经看过他们的文档 here.

虽然没有像 .submissions 调用那样的参数,但您可以使用 if 语句根据另一个 utc 时间戳检查 created_utc 来手动执行此操作。 (您可以使用 https://www.epochconverter.com/ 之类的东西来获得所需的时间戳)

以下代码示例获取 /u/spez 从去年圣诞节到今年圣诞节的所有评论。

import praw
oldest = 1482682380.0 #Timestamp for 12/25/16
newest = 1514218380.0 #Timestamp for 12/25/17
reddit = praw.Reddit('USER-AGENT-HERE')
for comment in reddit.redditor('spez').comments.new(limit= None):
    if comment.created_utc > oldest and comment.created_utc < newest:
        print "Comment Found! permalink: " + comment.permalink

考虑参考 Pushshift. You can get the comments by a user (let's say /u/avi8tr) at the following URL: Link .

Pushshift 也有一个 python 包装器(就像 PRAW 一样),但它正在开发中:GitHub Link。不过,您必须在 psraw/endpoints.py 中的 comment_search 中添加 'author' 参数。

注意:Pushshift 和 PSRAW 都在积极开发中。所以变化是意料之中的。