From ea68250d77e2469cadec5950f3790c2b7d16660d Mon Sep 17 00:00:00 2001 From: Michal Danilak Date: Wed, 2 Jan 2013 17:13:37 +0100 Subject: [PATCH] Added --spider option to "shell" command. --- scrapy/commands/shell.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scrapy/commands/shell.py b/scrapy/commands/shell.py index 289676218..fe45e7dba 100644 --- a/scrapy/commands/shell.py +++ b/scrapy/commands/shell.py @@ -28,6 +28,8 @@ class Command(ScrapyCommand): ScrapyCommand.add_options(self, parser) parser.add_option("-c", dest="code", help="evaluate the code in the shell, print the result and exit") + parser.add_option("--spider", dest="spider", + help="use this spider") def update_vars(self, vars): """You can use this function to update the Scrapy objects that will be @@ -37,9 +39,12 @@ class Command(ScrapyCommand): def run(self, args, opts): url = args[0] if args else None + spider = None + if opts.spider: + spider = self.crawler.spiders.create(opts.spider) shell = Shell(self.crawler, update_vars=self.update_vars, code=opts.code) self._start_crawler_thread() - shell.start(url=url) + shell.start(url=url, spider=spider) def _start_crawler_thread(self): t = Thread(target=self.crawler.start)