本文整理汇总了Python中searcher.Searcher.get_new_posts方法的典型用法代码示例。如果您正苦于以下问题:Python Searcher.get_new_posts方法的具体用法?Python Searcher.get_new_posts怎么用?Python Searcher.get_new_posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类searcher.Searcher
的用法示例。
在下文中一共展示了Searcher.get_new_posts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from searcher import Searcher [as 别名]
# 或者: from searcher.Searcher import get_new_posts [as 别名]
def main():
if POST_FILE.startswith("@"):
print "Please set the POST_FILE variable"
return
if not POLL_FREQ:
print "Please set the poll frequency. (should be atleast 45)"
return
s = Searcher(POLL_FREQ)
s.add_subreddit("forhire")
s.add_subreddit("jobbit")
s.add_subreddit("jobs4Bitcoins")
pynotify.init("Job Searcher")
while True:
new_posts = s.get_new_posts()
if(new_posts):
for subreddit in new_posts:
if(len(new_posts[subreddit]) < 5):
for post in new_posts[subreddit]:
n = pynotify.Notification(subreddit.display_name, post)
n.set_urgency(CRIT)
n.show()
print subreddit.display_name + " : " + post
else:
fp = open(POST_FILE, "a")
fp.write(asctime())
for post in new_posts[subreddit]:
fp.write(subreddit.display_name + " : " + post + "\n")
fp.close()
n = pynotify.Notification("New Posts!", "Too many new posts! New posts have been saved to ~/.new_posts.txt")
n.set_urgency(CRIT)
n.show()
sleep(s.poll_int)