进入scrapy shell
使用scrapy内置的scrapy shell,Scrapy Shell需要您预装好IPython(一个扩展的Python终端)。
您需要进入项目的根目录,执行下列命令来启动shell:
scrapy shell "http://www.dmoz.org/Computers/Programming/Languages/Python/Books/"
当您在终端运行Scrapy时,请一定记得给url地址加上引号,否则包含参数的url(例如
&
字符)会导致Scrapy运行失败。
scrapy shell命令设置USER_AGENT
scrapy shell -s USER_AGENT="Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" https://www.zhihu.com/question/265531388/answer/380051053