__init__.py 文件源码

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

项目:SuperOcto 作者: mcecchi 项目源码 文件源码
def _get_channel_data_from_network(self, key, config):
        """Fetch channel feed from network."""

        import requests

        url = config["url"]
        try:
            start = time.time()
            r = requests.get(url)
            self._logger.info(u"Loaded channel {} from {} in {:.2}s".format(key, config["url"], time.time() - start))
        except Exception as e:
            self._logger.exception(
                u"Could not fetch channel {} from {}: {}".format(key, config["url"], str(e)))
            return None

        response = r.text
        channel_path = self._get_channel_cache_path(key)
        with codecs.open(channel_path, mode="w", encoding="utf-8") as f:
            f.write(response)
        return feedparser.parse(response)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号