Skip to content

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

Remove "sel" shortcut from scrapy shell$

Daniel Grañad37308ad77ec
diff --git a/scrapy/shell.py b/scrapy/shell.py
index 6d81e0760..03024af4c 100644
--- a/scrapy/shell.py
+++ b/scrapy/shell.py
@@ -15,7 +15,6 @@ from scrapy.crawler import Crawler
from scrapy.exceptions import IgnoreRequest
from scrapy.http import Request, Response
from scrapy.item import BaseItem
-from scrapy.selector import Selector
from scrapy.settings import Settings
from scrapy.spider import Spider
from scrapy.utils.console import start_python_console
@@ -27,7 +26,7 @@ from scrapy.utils.spider import create_spider_for_request
class Shell(object):
relevant_classes = (Crawler, Spider, Request, Response, BaseItem,
- Selector, Settings)
+ Settings)
def __init__(self, crawler, update_vars=None, code=None):
self.crawler = crawler
@@ -99,7 +98,6 @@ class Shell(object):
self.vars['spider'] = spider
self.vars['request'] = request
self.vars['response'] = response
- self.vars['sel'] = Selector(response)
if self.inthread:
self.vars['fetch'] = self.fetch
self.vars['view'] = open_in_browser
diff --git a/scrapy/tests/test_command_shell.py b/scrapy/tests/test_command_shell.py
index 1fbb4b28a..a56236d54 100644
--- a/scrapy/tests/test_command_shell.py
+++ b/scrapy/tests/test_command_shell.py
@@ -31,7 +31,7 @@ class ShellTest(ProcessTest, SiteTest, unittest.TestCase):
@defer.inlineCallbacks
def test_response_selector_html(self):
- xpath = 'sel.xpath("//p[@class=\'one\']/text()").extract()[0]'
+ xpath = 'response.xpath("//p[@class=\'one\']/text()").extract()[0]'
_, out, _ = yield self.execute([self.url('/html'), '-c', xpath])
self.assertEqual(out.strip(), 'Works')