Skip to content

Instantly share code, notes, and snippets.

@ZenulAbidin
Last active March 27, 2020 19:52
Show Gist options
  • Save ZenulAbidin/0c81f9ee7859864323ab119e89def237 to your computer and use it in GitHub Desktop.
Save ZenulAbidin/0c81f9ee7859864323ab119e89def237 to your computer and use it in GitHub Desktop.
Template script that can retrieve the authors of reddit posts made after a specific date.
# Retrieves authors of the first 10 posts of /r/politics
# excluding deleted users.
# You can then feed these into DownloaderForReddit
# install pushift.py using `pip3 install pushshift.py`
# from pushshift_py import PushshiftAPI
# I don't know if 'banned_by_rpolitics' is someone's username
# or a banned user.
from pushshift_py import PushshiftAPI
api = PushshiftAPI()
import datetime as dt
start_epoch=int(dt.datetime(2017, 1, 1).timestamp())
l = list(api.search_submissions(after=start_epoch,
subreddit='politics',
filter=['author'],
limit=10))
authors = [i.author for i in l if i.author != '[deleted]']
print(' '.join(set(authors))) # set() deduplicates the list
# Gaybro1992 banned_by_rpolitics gazil9 therecordcorrected wurstfinga spike -StrangerThanFiction
print(authors)
# ['Gaybro1992', 'banned_by_rpolitics', 'gazil9', 'therecordcorrected', 'wurstfinga', 'spike', '-StrangerThanFiction']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment