Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

decode body from utf-8, as scrapy stores body as bytes, and twisted has already converted to unicode

Konstantin Lopuhin73ff87c1dc05
diff --git a/scrapy/core/downloader/webclient.py b/scrapy/core/downloader/webclient.py
index c335939d0..ba7bd798c 100644
--- a/scrapy/core/downloader/webclient.py
+++ b/scrapy/core/downloader/webclient.py
@@ -132,6 +132,9 @@ class ScrapyHTTPClientFactory(HTTPClientFactory):
status = int(self.status)
headers = Headers(self.response_headers)
respcls = responsetypes.from_args(headers=headers, url=self.url)
+ # XXX - scrapy response stores body as bytes,
+ # but maybe it makes sense to be able to store unicode?
+ body = to_bytes(body)
return respcls(url=self.url, status=status, headers=headers, body=body)
def _set_connection_attributes(self, request):