繁体   English   中英

如何从 Scrapy 中的 Request 获取响应?

[英]How can I get the response from the Request in Scrapy?

有什么方法可以从scrapy中的Request function获取response.body吗?

我有这个:

request = Request("http://www.example.com",  callback = self.mytest)

def mytest(self, response)
     return response.body

现在我想在 Python 变量中获取response.body ,如何获取?

我想要类似的东西

myresponse = Request("http://www.example.com").get('response')

有没有办法从刚刚创建的请求中获取响应? 不,只有回调函数有权访问响应。 进入回调后,您可以通过response.request访问请求,但反之则不能。

尝试使用 scrapy 内联请求: https://github.com/rmax/scrapy-inline-requests/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM