Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Nolan'
- import praw
- import pprint
- import sys
- username = "x"
- password = "x"
- user_agent = 'Test Script by /u/LovingThatPlaid'
- r = praw.Reddit(user_agent=user_agent)
- def logged_in_notification():
- global username
- global password
- r.login(username, password)
- if r.is_logged_in() == True:
- print("Logged in as LovingThatPlaid...")
- logged_in_notification()
- searched_user = input("What user would you like to search?: ")
- user = r.get_redditor(searched_user)
- thing_limit = input("How many of their comments would you like to parse?: ")
- while True:
- if type(thing_limit) == int:
- print("That is a number, thanks.")
- break
- elif type(thing_limit) == float:
- print("You need a whole number.")
- sys.exit()
- elif type(thing_limit) == str:
- print("You need a whole number.")
- sys.exit()
- else:
- print("That is a number, thanks.")
- break
- karma_by_subreddit = {}
- gen = user.get_submitted(limit=thing_limit)
- for thing in gen:
- subreddit = thing.subreddit.display_name
- karma_by_subreddit[subreddit] = (karma_by_subreddit.get(subreddit, 0)
- + thing.score)
- pprint.pprint(karma_by_subreddit)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement