1
Scrapy 1.0之前,我可能已經運行Scrapy殼牌對本地文件很簡單:對本地文件Scrapy殼
$ scrapy shell index.html
升級到1.0.3後,它開始拋出一個錯誤:
$ scrapy shell index.html
2015-10-12 15:32:59 [scrapy] INFO: Scrapy 1.0.3 started (bot: scrapybot)
2015-10-12 15:32:59 [scrapy] INFO: Optional features available: ssl, http11, boto
2015-10-12 15:32:59 [scrapy] INFO: Overridden settings: {'LOGSTATS_INTERVAL': 0}
Traceback (most recent call last):
File "/Users/user/.virtualenvs/so/bin/scrapy", line 11, in <module>
sys.exit(execute())
File "/Users/user/.virtualenvs/so/lib/python2.7/site-packages/scrapy/cmdline.py", line 143, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/Users/user/.virtualenvs/so/lib/python2.7/site-packages/scrapy/cmdline.py", line 89, in _run_print_help
func(*a, **kw)
File "/Users/user/.virtualenvs/so/lib/python2.7/site-packages/scrapy/cmdline.py", line 150, in _run_command
cmd.run(args, opts)
File "/Users/user/.virtualenvs/so/lib/python2.7/site-packages/scrapy/commands/shell.py", line 50, in run
spidercls = spidercls_for_request(spider_loader, Request(url),
File "/Users/user/.virtualenvs/so/lib/python2.7/site-packages/scrapy/http/request/__init__.py", line 24, in __init__
self._set_url(url)
File "/Users/user/.virtualenvs/so/lib/python2.7/site-packages/scrapy/http/request/__init__.py", line 59, in _set_url
raise ValueError('Missing scheme in request url: %s' % self._url)
ValueError: Missing scheme in request url: index.html
此行爲是打算還是這是Scrapy Shell中的錯誤?
作爲一種變通方法,我可以使用文件的絕對路徑在「文件」 URL方案:
$ scrapy shell file:////absolute/path/to/index.html
這是很明顯,更方便易行。
Scrapy已經將'scrapy shell index.html'視爲'scrapy shell http:// index.html /'。 https://github.com/scrapy/scrapy/pull/1498 爲了您的方便,您可以在* nix系統上將您的解決方法更改爲'scrapy shell file:// $ PWD/index.html'。 – digenishjkl
@digenishjkl感謝鏈接到變更集和nix系統的快捷方式。我想我應該在scrapy github問題跟蹤器中創建一個問題,以便我們可以恢復「方便」。 – alecxe
好的,在Scrapy github問題跟蹤器中創建了一個問題:https://github.com/scrapy/scrapy/issues/1550。 – alecxe