Last active
May 2, 2023 19:36
-
-
Save charlie-collard/6b5eff6670e4b839ffea89ceaed1aa0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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