thread = "39ai3d" result = get("/comments/#{thread}", [ ["depth", "10000"], ["limit", "10000"], ["sort", "top"] ] ) comments = [] parse_children[result[1]["data"]["children"]] def parse_children(children) children.each do |child| data = child["data"] case child["kind"] when "t1" comments << data["name"] parse_children data["replies"]["data"]["children"] when "more" data["children"].each_slice(100) do |slice| parse_children \ get("/api/morechildren", [ ["link_id", "t3_#{thread}"], ["children", slice.join(",")], ["sort", "top"] ] )["json"]["data"]["things"] end end end end puts "expected comments: #{result[0]["data"]["children"][0]["data"]["num_comments"]}" puts "#{comments.size} comments total for thread #{thread}"

Add a code snippet to your website: www.paste.org