Skip to content

Instantly share code, notes, and snippets.

@steeve85
Last active August 29, 2015 14:15
Show Gist options
  • Save steeve85/a6dfb3f2282b9f84b0b1 to your computer and use it in GitHub Desktop.
Save steeve85/a6dfb3f2282b9f84b0b1 to your computer and use it in GitHub Desktop.

Revisions

  1. steeve85 revised this gist Feb 18, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion redditInfosecJobs.py
    Original 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)
  2. steeve85 revised this gist Feb 18, 2015. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions redditInfosecJobs.py
    Original 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(com.id):
    self.offers[com.id] = com
    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(com.id):
    self.offers[com.id] = com
    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__':
  3. steeve85 created this gist Feb 18, 2015.
    49 changes: 49 additions & 0 deletions redditInfosecJobs.py
    Original 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)