Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Added settings to Scrapy shell variables

Pablo Hoffmanc276c48c9138
diff --git a/docs/topics/shell.rst b/docs/topics/shell.rst
index 87dc27d51..5bed14884 100644
--- a/docs/topics/shell.rst
+++ b/docs/topics/shell.rst
@@ -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:
diff --git a/scrapy/shell.py b/scrapy/shell.py
index 3390b34f1..af6060cd8 100644
--- a/scrapy/shell.py
+++ b/scrapy/shell.py
@@ -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)