[英]Get response from the request in Scrapy
is there a way i can return a response from my parse method?有没有办法可以从我的解析方法返回响应?
I tried this:我试过这个:
yield {
'content': scrapy.Request(url, callback=self.parse_page),
}
but the response is:但回应是:
'content': <GET https://example.com>
I expect the result would be like this:我希望结果是这样的:
'content': 'some text'
as the parse_page() method is parsing from some css selector.因为 parse_page() 方法是从一些 css 选择器中解析的。
Thank you and sorry for my bad english.谢谢你,对不起我的英语不好。
It is object:它是 object:
scrapy.Request(url, callback=self.parse_page)
Parameter body, this is what you need:参数体,这就是你需要的:
response = scrapy.Request(url, callback=self.parse_page)
content = response.body
yield {
'content': content,
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.