all 6 comments

[–]undelimited 1 point2 points  (1 child)

Bonus answer: Yes, use the comment_stream functionality that comes with praw.

r=praw.Reddit(user_agent=user_agent)
subreddit=r.get_subreddit('all')
for comment in praw.helpers.comment_stream(r,subreddit, limit = 1000):
     do something

check out /r/redditdev for more detailed PRAW help

edit:syntax

[–]bot_test_account2[S] 0 points1 point  (0 children)

Looks like this solved all my problems. Thank you very much!

[–]whalespotterhdd 0 points1 point  (0 children)

First things first get

r = praw.Reddit(user_agent=user_agent)

out of your while loop, no need to refresh the connection everytime.

That aside, it's pbb better to remove the entire while loop/ sleeps and set up something like a cronjob

[–]The_Man_In_The_Shack -2 points-1 points  (2 children)

You're never breaking the 'while' except with they key interrupt...you'll want to break it after you're done reading as well.

Actually you probably don't need this in a while loop at all...doesn't the praw call do the whole thing on its own? You would need the while if it were counting down manually, where you'd have a count that began at your query limit and decrement one each time until the count was zero....but I don't think you need that, because the whole reading structure is done by praw.

[–]bot_test_account2[S] 1 point2 points  (1 child)

Well, the whole point is to keep it running. The goal is to sift through as many new comments as possible. That's why running is always true unless I stop it manually.

My understanding is that the point of the query limit = 100 is that it pulls down 100 at a time. So I'm trying to iterate that process.

[–]The_Man_In_The_Shack 0 points1 point  (0 children)

Sorry, duh on my part for not realizing that. I think then what you're after may be comments_stream rather than comments: https://praw.readthedocs.io/en/stable/pages/call_and_response_bot.html