如何从 Scrapy 中的请求中获取响应?

use*_*027 5 python scrapy

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

我有这个:

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

def mytest(self, response)
     return response.body
Run Code Online (Sandbox Code Playgroud)

现在我想输入response.body一个Python变量,我怎样才能得到它?

我想要类似的东西

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

Ste*_*oth 5

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