From 5e54ac52ffef6ff00b4d881d16f164ac802b62d0 Mon Sep 17 00:00:00 2001 From: Damian Canabal Date: Tue, 4 Nov 2008 17:45:26 +0000 Subject: [PATCH] fixed new_response_from_xpaths function, unicode string was passed as body instead of ResponseBody object --HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40365 --- scrapy/trunk/scrapy/utils/response.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scrapy/trunk/scrapy/utils/response.py b/scrapy/trunk/scrapy/utils/response.py index 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 ResponseBody def 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()))