2017-06-22 59 views

回答

2

我把它通過運行下面的Python代碼片段工作:

from scrapy.cmdline import execute 
import sys 
sys.argv = ['scrapy', 'shell', 'http://scrapy.org'] 
execute() 

如果您收到以下錯誤:

MultipleInstanceError: Multiple incompatible subclass instances of InteractiveShellEmbed are being created. 

,那麼你必須添加到scrapy.cfg以下行:

shell=python 
+0

當我嘗試使用這個方法時,我用'ipython'(我的首選shell)得到'MultipleInstanceError',即使用'shell = ipython'寫成[docs](https://doc.scrapy.org/zh/latest/topics/ shell.html#configurations-the-shell),但是使用普通的shell就可以工作。 –

+0

另一個限制 - 不在遠程解釋器中工作 –

1

您在pycharm窗口底部有一個終端圖標。

enter image description here

它會打開一個新的終端,您可以在其中運行scrapy shell

+1

問題不在於此。問題是:「如何在PyCharm ** python控制檯**中運行'scrapy shell'?」 –

+0

對不起,誤會。從[官方文檔](https://www.jetbrains.com/help/pycharm/loading-code-from-editor-into-console.html),沒有任何內容表明這是可能的。我希望有人有答案。 –