base.py 文件源码

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

项目:wdom 作者: miyakogi 项目源码 文件源码
def fetch(self, url: str, encoding: str = 'utf-8') -> HTTPResponse:
        """Fetch url and return ``tornado.httpclient.HTTPResponse`` object.

        Response body is decoded by ``encoding`` and set ``text`` property of
        the response. If failed to decode, ``text`` property will be ``None``.
        """
        response = await to_asyncio_future(
            AsyncHTTPClient().fetch(url, raise_error=False))
        if response.body:
            try:
                response.text = response.body.decode(encoding)
            except UnicodeDecodeError:
                response.text = None
        else:
            response.text = None
        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号