From 505dfe6f7e5d980c76d30e223e883daa02bfdb52 Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Fri, 13 Nov 2009 17:21:59 -0200 Subject: [PATCH] fixed exception when running scrapy shell on a non-textual response (fixes #116) --- scrapy/shell.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scrapy/shell.py b/scrapy/shell.py index 9c0298502..8af6af006 100644 --- a/scrapy/shell.py +++ b/scrapy/shell.py @@ -18,7 +18,7 @@ from scrapy.utils.response import open_in_browser from scrapy.conf import settings from scrapy.core.manager import scrapymanager from scrapy.core.engine import scrapyengine -from scrapy.http import Request +from scrapy.http import Request, TextResponse def relevant_var(varname): return varname not in ['shelp', 'fetch', 'view', '__builtins__', 'In', \ @@ -67,8 +67,9 @@ class Shell(object): item = self.item_class() self.vars['item'] = item if url: - self.vars['xxs'] = XmlXPathSelector(response) - self.vars['hxs'] = HtmlXPathSelector(response) + if isinstance(response, TextResponse): + self.vars['xxs'] = XmlXPathSelector(response) + self.vars['hxs'] = HtmlXPathSelector(response) self.vars['url'] = url self.vars['response'] = response self.vars['request'] = request