【问题标题】:Praw (Reddit API) How to retrieve replies to a comment past 10 levels deepPraw(Reddit API)如何检索对超过 10 级深度的评论的回复
【发布时间】:2014-08-21 00:58:21
【问题描述】:

好的,所以我编写了一些代码,无论出于何种意图和目的,它们都应该可以工作:

def checkComments(comments):
  for comment in comments:
    print comment.body
    checkComments(comment.replies)

def processSub(sub):
  sub.replace_more_comments(limit=None, threshold=0)
  checkComments(sub.comments)


#login and subreddit init stuff here
subs = mysubreddit.get_hot(limit=25)
for sub in subs:
  processSub(sub)

但是,如果提交的评论包含 50 个嵌套回复,如下所示:

root comment
-> 1st reply
   -> 2nd reply
      -> 3rd reply
         ...
           -> 50th reply

以上代码只打印:

root comment
1st reply
2nd reply
3rd reply
4th reply
5th reply
6th reply
7th reply
8th reply
9th reply

知道如何获得剩余的 41 级回复吗?或者这是一个 praw 限制?

【问题讨论】:

    标签: python reddit praw


    【解决方案1】:

    首先,limit 限制了结果的数量,而不是结果的深度。

    但这不是这里的问题,reddit API 的morecomments 端点似乎为深度嵌套的 cmets 返回了错误的结果。

    更多技术细节,请参考bug report #321

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-17
      • 2014-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      • 2020-02-10
      • 1970-01-01
      相关资源
      最近更新 更多