Scrapy, a fast high-level web crawling & scraping framework for Python.
fixed exception when running scrapy shell on a non-textual response (fixes #116)
Pablo Hoffman505dfe6f7e5d
diff --git a/scrapy/shell.py b/scrapy/shell.pyindex 9c0298502..8af6af006 100644--- a/scrapy/shell.py+++ b/scrapy/shell.py@@ -18,7 +18,7 @@ from scrapy.utils.response import open_in_browserfrom scrapy.conf import settingsfrom scrapy.core.manager import scrapymanagerfrom scrapy.core.engine import scrapyengine-from scrapy.http import Request+from scrapy.http import Request, TextResponsedef 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'] = itemif 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'] = urlself.vars['response'] = responseself.vars['request'] = request