Is there a way to bulk subscribe to all subreddits in a particular list programmatically (there is no built-in way to do this)

Viewed 773

Currently the list is return-separated and " (break)" separated as well, but of course it could be in any other format such as csv. or whatever.

Hoping someone here could help me. I scoured google to try and find a solution but couldn't for the life of me, I must be missing something in my search! I'm surprised that nobody else would like this functionality.

1 Answers

here is a naive solution with praw, it assumes you have a text file containing the subreddits you wish to subscribe to (separate lines for each subreddit) and a custom application added to your reddit account:

import praw

reddit = praw.Reddit(
    user_agent="mass sub",

    # visit https://old.reddit.com/prefs/apps/ to add a new script
    # choose http://localhost:8080 as a random and unused callback url 

    client_id="",
    client_secret="",
    username="",
    password=""
)

# for each in list of subreddits call this
file1 = open('./some_txt_file_of_subreddits', 'r')

Lines = file1.readlines()

for line in Lines:
    print("Line: {}".format(line.strip()))
    reddit.subreddit(line.strip()).subscribe()

if you need to generate a list of subreddits from an existing account you can use this bookmarklet

The bookmarklet script below should be run on https://www.reddit.com/subreddits/mine/

javascript:$('body').replaceWith('<body>'+$('.subscription-box').find('li').find('a.title').map((_, d) => $(d).text()).get().join("<br>")+'</body>');javascript.void()

where the output can be saved to a text file

Related