2015-06-23 99 views
6

我想多个用户定义的参数传递给我的scrapy Spyder的,所以我试图按照这个帖子:How to pass a user defined argument in scrapy spider如何将多个参数传递给Scrapy蜘蛛(不再支持多个蜘蛛运行'scrapy爬行'错误)?

然而,当我照做那里我得到一个错误:

[email protected] scrapy crawl dmoz -a address= 40-18 48th st -a borough=4 
Usage 
===== 
    scrapy crawl [options] <spider> 

crawl: error: running 'scrapy crawl' with more than one spider is no longer supported 

我也试过各种引号排列:

[email protected] scrapy crawl dmoz -a address= "40-18 48th st" -a borough="4" 
Usage 
===== 
    scrapy crawl [options] <spider> 
crawl: error: running 'scrapy crawl' with more than one spider is no longer supported 

将参数传递给Scrapy蜘蛛的正确方法是什么?我想为蜘蛛的登录/抓取过程传递一个用户名和密码。感谢您的任何建议。

回答

9

scrapy问题,我猜。这就是您的shell如何解释输入,并在空间中分割令牌。所以,你不能在关键和价值之间有任何一个。试一下:

scrapy crawl dmoz -a address="40-18 48th st" -a borough="4" 
+0

我也试过这个选项。如果有问题,我正在使用Ubuntu,但我已经尝试了输入和输入名称上的每个引号的排列组合。除非我错过了某些东西,否则你所说的正是我在问题结尾处所做的事情,作为我已经尝试过的一个例子? – sunny

+0

@sunny:当然,你尝试过我的解决方案,也没有工作吗?这不一样。 '-a'开关接受'key = value'参数,但shell在'scrapy'之前处理输入,'='后面的空格使它产生两个不同的标记,'scrapy'解释为另一个标记蜘蛛。 – Birei

+0

我刚刚复制并粘贴了你的行,它给了我与上面粘贴的完全相同的错误。 – sunny