好了,我已经写了一些代码,从所有的意图和目的来看,应该可以工作了:
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层回复吗?或者这是虾的限制?
首先,limit
限制了结果的数量,而不是结果的深度。
但这不是这里的问题,morecomments
端点的reddit API似乎返回错误的结果为深嵌套的评论。
有关更多技术细节,请参阅bug报告#321。