__init__.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:rss_skill 作者: forslund 项目源码 文件源码
def get_items(self, name):
        """
            Get items from the named feed, if cache exists use cache otherwise
            fetch the feed and update.
        """
        cache_timeout = 10 * 60
        cached_time = float(self.cache_time.get(name, 0))

        if name in self.cached_items \
                and (time.time() - cached_time) < cache_timeout:
            logger.debug('Using cached feed...')
            return self.cached_items[name]
        else:
            logger.debug('Fetching feed and updating cache')
            feed = feedparser.parse(self.feeds[name])
            feed_items = feed.get('items', [])
            self.cache(name, feed_items)

            if len(feed_items) > 5:
                return feed_items[:5]
            else:
                return feed_items
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号