Last active
August 29, 2015 14:15
-
-
Save steeve85/a6dfb3f2282b9f84b0b1 to your computer and use it in GitHub Desktop.
List Infosec Jobs on Reddit
This file contains 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
#!/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("%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) | |
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("%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__': | |
r = Reddit() | |
r.get_comments() | |
r.print_all_comments() | |
while True: | |
r.refresh() | |
time.sleep(3600) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment