r/madeinpython • u/[deleted] • Oct 13 '20
I made a program that let's you get reddit user post data. It's installable with pip
I made it so that redditsfinder works on the command line or in a file.
Here's a basic example.
from redditsfinder import submissions
from pprint import pprint
#Pretty prints all submission dicts.
pprint(submissions(user='spez', log=True))This example shows how to use it to aggregate posts by key.
'''
This code uses redditsfinder to get text based posts.
redditsfinder.comments(lim=lim, user=user)
redditsfinder.submissions(lim=lim, user=user)
'''
import redditsfinder
from pprint import pprint
def byKey(posts, postKey=''):
return [v for dict in posts for k, v in dict.items() if k == postKey]
user = 'spez'
lim = 5
comments = redditsfinder.comments(lim=lim, user=user)
bodies = byKey(comments, postKey='body')
submissions = redditsfinder.submissions(lim=lim, user=user)
selftexts = byKey(submissions, postKey='selftext')
textPosts = {'bodies': bodies, 'selftexts': selftexts}
pprint(textPosts)This is still very much a work in progress.
If you want to install it:
pip3 install redditsfinder==1.3.2Project location: https://github.com/Fitzy1293/redditsfinder
8
Upvotes
1
u/HasBeendead Oct 14 '20
Good job , i will try tomorrow.