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")