2015-06-23 101 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