Created
January 21, 2019 13:58
-
-
Save gavin19/a69d0a50d109a5171facffd1c77050c7 to your computer and use it in GitHub Desktop.
Print list of upvoted links on reddit by count per subreddit, then subreddit name.
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
import praw | |
def main(): | |
r = praw.Reddit(user_agent='/u/someuser upvoted counter', | |
client_id='CLIENT_ID', client_secret='CLIENT_SECRET', | |
username='USERNAME', password='PASSWORD') | |
liked = r.user.me().upvoted(limit=None) | |
likes = {} | |
for l in liked: | |
sub = l.subreddit.display_name | |
if sub in likes: | |
likes[sub] += 1 | |
else: | |
likes[sub] = 1 | |
likes = sorted(likes.items(), key=lambda v: (-v[1], v[0].lower())) | |
for l in likes: | |
print(l[0] + ": " + str(l[1])) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment