jpreed00
jpreed00

Reputation: 893

Praw (Reddit API) How to retrieve replies to a comment past 10 levels deep

Ok, so I've written some code that, for all intents and purposes, should work:

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)

However, given a submission with a comment that has 50 nested replies like so:

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

The above code only prints:

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

Any idea how I can get the remaining 41 levels of replies? Or is this a praw limitation?

Upvotes: 0

Views: 1073

Answers (1)

phihag
phihag

Reputation: 287885

First of all, limit limits the number of results, not the result depth.

But that's not the problem here, the morecomments endpoint of the reddit API seems to return wrong results for deeply nested comments.

For more technical details, refer to bug report #321.

Upvotes: 3

Related Questions