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.

Revisions

  1. charlie-collard renamed this gist May 2, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. charlie-collard created this gist May 2, 2023.
    24 changes: 24 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    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")