Last active
March 23, 2021 15:24
-
-
Save Zren/82befb7bf63e3d9156de1bbd48b0ffef to your computer and use it in GitHub Desktop.
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 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