Scrapy, a fast high-level web crawling & scraping framework for Python.
fixed new_response_from_xpaths function, unicode string was passed as body instead of ResponseBody object
Damian Canabal5e54ac52ffef
diff --git a/scrapy/trunk/scrapy/utils/response.py b/scrapy/trunk/scrapy/utils/response.pyindex 63fa3f686..3e16d92b1 100644--- a/scrapy/trunk/scrapy/utils/response.py+++ b/scrapy/trunk/scrapy/utils/response.py@@ -4,6 +4,7 @@ scrapy.http.Response objects"""from scrapy.xpath import XPathSelector+from scrapy.http.response import ResponseBodydef new_response_from_xpaths(response, xpaths):"""Return a new response constructed by applying the given xpaths to the@@ -11,5 +12,5 @@ def new_response_from_xpaths(response, xpaths):"""xs = XPathSelector(response)parts = [''.join([n for n in xs.x(x).extract()]) for x in xpaths]- new_body = ''.join(parts)- return response.replace(body=new_body)+ new_body_content = ''.join(parts)+ return response.replace(body=ResponseBody(content=new_body_content, declared_encoding=response.body.get_declared_encoding()))