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


Python Response.runtime_body方法代码示例

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


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

示例1: build_response

# 需要导入模块: from grab.response import Response [as 别名]
# 或者: from grab.response.Response import runtime_body [as 别名]
    def build_response(self, resource):
        response = Response()
        response.head = ''
        response.code = resource.status_code

        runtime_body = self.page.mainFrame().toHtml()
        body = resource.reply.data
        url = resource.reply.url().toString()
        headers = resource.headers
        cookies = self.get_cookies()

        # py3 hack
        if PY3K:
            if isinstance(body, QByteArray):
                body = body.data()
            headers = decode_dict(headers)
            cookies = decode_dict(cookies)
        else:
            runtime_body = unicode(runtime_body)
            body = str(body)
            url = str(url)

        response.runtime_body = runtime_body.encode('utf-8')
        response.body = body
        response.url = url
        response.parse(charset='utf-8')
        response.headers = headers
        response.cookies = cookies

        return response
开发者ID:Scaurus,项目名称:grab,代码行数:32,代码来源:__init__.py

示例2: build_response

# 需要导入模块: from grab.response import Response [as 别名]
# 或者: from grab.response.Response import runtime_body [as 别名]
 def build_response(self, resource):
     response = Response()
     response.head = ''
     response.runtime_body = unicode(self.page.mainFrame().toHtml()).encode('utf-8')
     response.body = str(resource.reply.data)
     response.code = resource.status_code
     response.url = str(resource.reply.url().toString())
     response.parse(charset='utf-8')
     response.headers = resource.headers
     response.cookies = self.get_cookies()
     return response
开发者ID:vasia123,项目名称:grab,代码行数:13,代码来源:__init__.py


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