scrapy 2.3 shell启动外壳
要启动碎屑壳,可以使用 shell 命令如下:
scrapy shell <url>
何处 <url> 是要擦除的URL。
shell 也适用于本地文件。如果你想玩一个网页的本地副本,这很方便。 shell 了解本地文件的以下语法::
# 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
注解
使用相对文件路径时,请显式并用 ./ (或) ../ 相关时)。 scrapy shell index.html 不会像人们预期的那样工作(这是设计上的,而不是错误)。
因为 shell 喜欢HTTP URL而不是文件URI,以及 index.html 在句法上类似于 example.com , shell 会治疗 index.html 作为域名并触发DNS查找错误::
$ scrapy shell index.html
[ ... scrapy shell starts ... ]
[ ... traceback ... ]
twisted.internet.error.DNSLookupError: DNS lookup failed:
address 'index.html' not found: [Errno -5] No address associated with hostname.
shell 如果文件调用了 index.html 存在于当前目录中。同样,要明确。