Skip to content

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

PY3 port responsetypes from_body

Gregory Vigo Torres42b8988eb2ca
diff --git a/scrapy/responsetypes.py b/scrapy/responsetypes.py
index 3e3518e79..b519c56d3 100644
--- a/scrapy/responsetypes.py
+++ b/scrapy/responsetypes.py
@@ -90,6 +90,7 @@ class ResponseTypes(object):
it's not meant to be used except for special cases where response types
cannot be guess using more straightforward methods."""
chunk = body[:5000]
+ chunk = to_bytes(chunk)
if isbinarytext(chunk):
return self.from_mimetype('application/octet-stream')
elif b"<html>" in chunk.lower():