Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import pprint
- import json
- filename = 'user.subs'
- user_agent = 'test-py'
- client_id='xxx'
- client_secret="xxx"
- username='xxx'
- password='xxx'
- reddit = praw.Reddit(user_agent=user_agent,
- client_id=client_id, client_secret=client_secret,
- username=username, password=password)
- try:
- x = reddit.user.me()
- my_subs = set()
- for sub in reddit.user.subreddits(limit=None):
- my_subs.add(str(sub))
- pprint.pprint(my_subs)
- fh = open(filename, 'w')
- subs = sorted(my_subs, key=str.lower)
- json.dump(subs, fh, indent=2)
- fh.close()
- except Exception as exc:
- pprint.pprint(vars(exc))
Add Comment
Please, Sign In to add comment