3

Is there any way that I can get the response.body from the Request function in scrapy?

I have this:

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

def mytest(self, response)
     return response.body

Now I want to get response.body in a Python variable, How can I get that?

I want something like

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

4

1 回答 1

2

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

于 2012-12-27T18:17:33.603 回答