siesta.py 文件源码

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

项目:aquests 作者: hansroh 项目源码 文件源码
def set_data (self, resp):
        if not resp.text.strip ():
            self.data = None

        else:   
            ct = resp.headers.get ('content-type')
            if ct is None or ct.find ('text/html') == 0:
                h = html2text.HTML2Text()
                h.ignore_links = True
                text = h.handle(resp.text)
                self.data = text

            elif ct is None or ct.find ('text/') == 0:
                self.data = resp.text.strip ()
            else:
                data = resp.json ()
                if isinstance (data, dict):
                    self.data.update (data)
                else:
                    self.data = data

        if not str(resp.status_code).startswith("2"):           
            raise AssertionError ("%s %s\n%s\n%s" % (resp.status_code, resp.reason, "-" * (20 + len (resp.reason)), self))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号