You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Inomnibus/RedditCommentsParser.py

21 lines
805 B

import praw
from datetime import datetime
class RedditComments:
def __init__(self, link):
self.reddit = praw.Reddit(client_id='unBoGZxgkQSk8KsKWr_jag',
client_secret=None,
redirect_uri='http://localhost:8888',
user_agent='agent',
check_for_async=False)
self.comments = []
self.link = link
def getComments(self):
submission = self.reddit.submission(url=self.link)
for comment in submission.comments:
comment_date = datetime.utcfromtimestamp(comment.created_utc).strftime('%Y-%m-%d %H:%M:%S')
self.comments.append(str(comment.author) + " " + str(comment_date) + "\n" + str(comment.body) + "\n")