Last active
August 29, 2015 14:15
-
-
Save steeve85/a6dfb3f2282b9f84b0b1 to your computer and use it in GitHub Desktop.
Revisions
-
steeve85 revised this gist
Feb 18, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,6 @@ def get_comments(self): if not self.offers.has_key("%s-%s-%s" % (com.id, com.subreddit, sub)): self.offers["%s-%s-%s" % (com.id, com.subreddit, sub)] = com def print_comment(self, com): print "\033[31m[%s] \033[33m - %s by %s" % (com.subreddit, datetime.datetime.utcfromtimestamp(com.created_utc), com.author) print "\033[37m %s" % (com.body) -
steeve85 revised this gist
Feb 18, 2015 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,9 @@ def get_comments(self): forest_comments = submission.comments for com in forest_comments: if not self.offers.has_key("%s-%s-%s" % (com.id, com.subreddit, sub)): self.offers["%s-%s-%s" % (com.id, com.subreddit, sub)] = com def print_comment(self, com): print "\033[31m[%s] \033[33m - %s by %s" % (com.subreddit, datetime.datetime.utcfromtimestamp(com.created_utc), com.author) @@ -36,8 +37,8 @@ def refresh(self): forest_comments = submission.comments for com in forest_comments: if not self.offers.has_key("%s-%s-%s" % (com.id, com.subreddit, sub)): self.offers["%s-%s-%s" % (com.id, com.subreddit, sub)] = com self.print_comment(com) if __name__ == '__main__': -
steeve85 created this gist
Feb 18, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/usr/bin/env python import praw, datetime, time class Reddit: def __init__(self): self.submissions = ['2s9m3i', '2rijej'] # to update when they change self.offers = {} self.r = praw.Reddit('Infosec jobs on Reddit') def get_comments(self): for sub in self.submissions: submission = self.r.get_submission(submission_id=sub) forest_comments = submission.comments for com in forest_comments: if not self.offers.has_key(com.id): self.offers[com.id] = com def print_comment(self, com): print "\033[31m[%s] \033[33m - %s by %s" % (com.subreddit, datetime.datetime.utcfromtimestamp(com.created_utc), com.author) print "\033[37m %s" % (com.body) print "\033[34m --> %s\033[0m" % (com.permalink) print """ --- """ def print_all_comments(self): for com_id in sorted(self.offers.keys()): self.print_comment(self.offers[com_id]) def refresh(self): for sub in self.submissions: submission = self.r.get_submission(submission_id=sub) forest_comments = submission.comments for com in forest_comments: if not self.offers.has_key(com.id): self.offers[com.id] = com self.print_comment(com) if __name__ == '__main__': r = Reddit() r.get_comments() r.print_all_comments() while True: r.refresh() time.sleep(3600)