mirror of https://github.com/scrapy/scrapy.git
fixed exception when running scrapy shell on a non-textual response (fixes #116)
This commit is contained in:
parent
f3e861c89e
commit
505dfe6f7e
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue