Luke Prior
Luke Prior

Reputation: 967

How to fetch all subreddits PRAW/PSAW

Hi I have a program where i want to loop through all subreddits:

for subreddit in reddit.subreddits.default(limit=None):

The code above however only fetches around about the top 100 subreddits.

PSAW seems to only support comments and submissions so how can I loop through all subreddits and feed them into PRAW?

Thanks

Upvotes: 0

Views: 2313

Answers (2)

Alex Cooper
Alex Cooper

Reputation: 39

.default() only gives you default subreddits

The PRAW docs show the different search options available for subreddits.

If you're set on going this route I imagine you could use .search_by_name() in a for loop where each search starts with a different letter. But keep in mind you're limited to 1000 results per loop this method.

Upvotes: 0

LampToast
LampToast

Reputation: 553

praw does not provide a way to get a list of all subreddits. You can download and read from the .csv files provided Here. You can see as of 11 October 2019 there are over 1.68 million subreddits. The person who created that website says they update the files on a weekly basis.

Upvotes: 1

Related Questions