Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save charlie-collard/6b5eff6670e4b839ffea89ceaed1aa0f to your computer and use it in GitHub Desktop.
Save charlie-collard/6b5eff6670e4b839ffea89ceaed1aa0f to your computer and use it in GitHub Desktop.
from collections import defaultdict
import praw
reddit = praw.Reddit(client_id='client_id',
client_secret='client_secret',
user_agent='user_agent',
password='password',
username='username')
mods_to_subs = defaultdict(list)
subreddits = reddit.subreddits.popular(limit=100)
for subreddit in subreddits:
try:
for moderator in subreddit.moderator():
mods_to_subs[moderator.name].append(subreddit.display_name)
except Exception as e:
print(e)
print(f'Failed to get moderators for /r/{subreddit.display_name}')
for mod, subs in sorted(mods_to_subs.items(), key=lambda x: -len(x[1])):
print(f"{mod} moderates {len(subs)} subreddits: {subs}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment