2016-10-14 80 views
1

其實它是一個樣本的scrapy教程提取數據scrapy。一切順利,直到scrapy殼的樣品,當我輸入在Windows CMD命令:蟒蛇scrapy殼例外:地址「'http:」找不到:[Errno 11001] getaddrinfo失敗

scrapy shell 'http://quotes.toscrape.com/page/1/' 

我喜歡在線程的線程1

twisted.internet.error.DNSLookupError: DNS lookup failed: address "'http:" not found: [Errno 11001] getaddrinfo failed. 

異常的異常(翻譯過程中最有可能上調關機):

詳細滋味: [scrapy shell exception] ,我已經搜查了stackoverflow並找到像question類似的問題和一個答案是嘗試另一個終端,我嘗試了Pycharm的終端,但它失敗,同樣的異常。

PS:我在Windows和Python 2.7.12工作,蟒蛇4.0.0(64位)

我是很新的scrapy所以任何幫助表示讚賞,謝謝。

回答

8

嗯,這可能與報價,我試圖用"圍住URL和它的作品,我不知道這個命令在不同的操作系統不同,因爲原來的教程條命令代碼中使用'包圍網址。


我也張貼在scrapy這個問題,併爲@kmike說,它與'行之有效其他操作系統一樣(MAC和Linux或Unix)(github

+0

簡單的解決方案,我可能需要幾個小時才能找到...謝謝! –

1

對於任何人發現這個問題對於一個本地的.html文件,同樣的錯誤,我發現我必須在當前文件夾前加上文件名,而不僅僅是提供文件名。

錯誤

twisted.internet.error.DNSLookupError: DNS lookup failed: address 'local_file.htm' not found: [Errno 8] nodename nor servname provided, or not known.

但是使用

scrapy shell local_file.html 

結果,使用

scrapy shell ./local_file.html 

啓動外殼並加載該文件。

儘管文件路徑的格式爲specified in the docs,我沒有意識到這將需要(我以爲我就不必爲本地文件提供./),但該文檔做給學習的榜樣。

shell also works for local files. This can be handy if you want to play around with a local copy of a web page. shell understands the following syntaxes for local files:

UNIX-style

scrapy shell ./path/to/file.html

scrapy shell ../other/path/to/file.html

scrapy shell /absolute/path/to/file.html

File URI

scrapy shell file:///absolute/path/to/file.html