body_as_unipre是TextResponse的方法。如果http响应包含文本内容,则scrapy将创建TextResponse或其子类之一(例如HtmlResponse)。
In [1]: fetch('http://scrapy.org')...In [2]: type(response)Out[2]: scrapy.http.response.html.HtmlResponse...In [3]: fetch('http://www.scrapy.org/site-media/images/logo.png')...In [4]: type(response)Out[4]: scrapy.http.response.Response在您的情况下,最可能的解释是scrapy认为回复中没有文字。
来自服务器的HTTP响应是否正确设置了Content-Type标头?是否可以在浏览器中正确呈现?这些问题将有助于了解它是预期的行为还是错误。



