Skip to content

Instantly share code, notes, and snippets.

@Zren
Last active Mar 23, 2021
Embed
What would you like to do?
import os
import datetime
import praw
reddit = praw.Reddit(
client_id='...',
client_secret='...',
user_agent='RedditUserHistory.py',
username='...',
password='...'
)
username = 'Zren'
user = reddit.redditor(username)
os.makedirs('./{}/'.format(username), exist_ok=True)
for comment in user.comments.new(limit=None):
created_dt = datetime.datetime.utcfromtimestamp(comment.created_utc)
print(created_dt, comment.subreddit)
filepath = "{}/{}.log".format(username, comment.subreddit)
with open(filepath, "a") as fout:
text = comment.permalink + '\n'
text += comment.body + '\n'
text += '\n\n\n'
fout.write(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment