mirror of https://github.com/scrapy/scrapy.git
Added settings to Scrapy shell variables
This commit is contained in:
parent
b8b7b5ad74
commit
c276c48c91
|
|
@ -89,6 +89,8 @@ Those objects are:
|
|||
* ``xxs`` - a :class:`~scrapy.selector.XmlXPathSelector` object constructed
|
||||
with the last response fetched
|
||||
|
||||
* ``settings`` - the current :ref:`Scrapy settings <topics-settings>`
|
||||
|
||||
Example of shell session
|
||||
========================
|
||||
|
||||
|
|
@ -116,6 +118,7 @@ all start with the ``[s]`` prefix)::
|
|||
[s] item Item()
|
||||
[s] request <http://scrapy.org>
|
||||
[s] response <http://scrapy.org>
|
||||
[s] settings <Settings 'mybot.settings'>
|
||||
[s] spider <scrapy.spider.models.BaseSpider object at 0x2bed9d0>
|
||||
[s] xxs <XmlXPathSelector (http://scrapy.org) xpath=None>
|
||||
[s] Useful shortcuts:
|
||||
|
|
|
|||
|
|
@ -17,12 +17,13 @@ from scrapy.utils.misc import load_object
|
|||
from scrapy.utils.response import open_in_browser
|
||||
from scrapy.utils.url import any_to_uri
|
||||
from scrapy.utils.console import start_python_console
|
||||
from scrapy.conf import settings
|
||||
from scrapy.conf import settings, Settings
|
||||
from scrapy.http import Request, Response, TextResponse
|
||||
|
||||
class Shell(object):
|
||||
|
||||
relevant_classes = (BaseSpider, Request, Response, BaseItem, XPathSelector)
|
||||
relevant_classes = (BaseSpider, Request, Response, BaseItem, \
|
||||
XPathSelector, Settings)
|
||||
|
||||
def __init__(self, crawler, update_vars=None, inthread=False):
|
||||
self.crawler = crawler
|
||||
|
|
@ -71,6 +72,7 @@ class Shell(object):
|
|||
def populate_vars(self, url=None, response=None, request=None, spider=None):
|
||||
item = self.item_class()
|
||||
self.vars['item'] = item
|
||||
self.vars['settings'] = settings
|
||||
if url:
|
||||
if isinstance(response, TextResponse):
|
||||
self.vars['xxs'] = XmlXPathSelector(response)
|
||||
|
|
|
|||
Loading…
Reference in New Issue