当前位置: 首页>>代码示例>>Python>>正文


Python Searcher.add_subreddit方法代码示例

本文整理汇总了Python中searcher.Searcher.add_subreddit方法的典型用法代码示例。如果您正苦于以下问题:Python Searcher.add_subreddit方法的具体用法?Python Searcher.add_subreddit怎么用?Python Searcher.add_subreddit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在searcher.Searcher的用法示例。


在下文中一共展示了Searcher.add_subreddit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from searcher import Searcher [as 别名]
# 或者: from searcher.Searcher import add_subreddit [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)
开发者ID:vinay-nadig,项目名称:util_scripts,代码行数:41,代码来源:poll.py


注:本文中的searcher.Searcher.add_subreddit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。