Skip to content
yeongmin's archive
yeongmin's archive

idk what I'm doing

  • Main
  • 📣Minecraft server
  • Making a Reddit scraper (2023)
    • So, about the BAscraper
      • First release of BAScraper
    • stuffs from BAnalyser.ipynb (r/bluearchive recap)
    • Some notes on the new API policy for reddit
    • What counts as a request? (PRAW)
    • Some notes on PRAW
  • Homelabs n’ Servers
yeongmin's archive

idk what I'm doing

What counts as a request? (PRAW)

maxjo, 2023-12-242023-12-27

Reddit allows requests of up to 100 items at once. So if you request <= 100 items PRAW can serve your request in a single API call, but for larger requests PRAW will break it into multiple API calls of 100 items each separated by a small 2 second delay to follow the api guidelines. So requesting 250 items will require 3 api calls and take at least 2×2=4 seconds due to API delay. PRAW does the API calls lazily, i.e. it will not send the next api call until you actually need the data. Meaning the runtime is max(api_delay, code execution time).

Regarding comment extraction:

from praw.models import MoreComments

for top_level_comment in submission.comments:
    if isinstance(top_level_comment, MoreComments):
        continue
    print(top_level_comment.body)

In the above snippet, isinstance() is used to check whether the item in the comment list was a MoreComments so that we could ignore it. But there is a better way: the CommentForest object has a method called replace_more(), which replaces or removes MoreComments objects from the forest.
Each replacement requires one network request, and its response may yield additional MoreComments instances. As a result, by default, replace_more() only replaces at most 32 MoreComments instances – all other instances are simply removed. The maximum number of instances to replace can be configured via the limit parameter.

from PRAW Docs

PRAW

Post navigation

Previous post
Next post

Related Posts

Few notes on the new API policy for reddit

2023-12-242023-12-27

Reddit’s 2023 API changes have introduced some significant modifications that could affect your use of the Reddit Python API package. Key aspects of these changes include: 1. Usage-based Pricing: Reddit’s new API pricing structure is based on usage levels. As of July 1, 2023, applications making less than 100 queries…

Read More

Some notes on PRAW

2023-12-272023-12-27

Edit: PRAW has some severe limitations that made me change my mind. PRAW, after some recent updates, removed all the date range functions and added hard limitations to the amount of posts it can fetch. a few years ago, when I tried to do this before, I used a hybrid…

Read More
©2025 yeongmin's archive