安装ipython,使用scrapy shell来验证xpath选择的结果

python学习网 2017-07-14 15:56:05

1. scrapy shell

是scrapy包的一个很好的交互性工具,目前我使用它主要用于验证xpath选择的结果。安装好了scrapy之后,就能够直接在cmd上操作scrapy shell了。

具体的解释参考官网

https://docs.scrapy.org/en/latest/topics/shell.html

 

2. ipython

在官网推荐使用ipython来跑scrapy shell,于是我尝试安装。因为之前我的python环境都是通过conda配置的(参看前一篇),通过conda安装ipython很方便

conda install -c conda-forge ipython

然后整个ipython的包就会下载下来,因为都是编译好的,没有了烦人的编译失败的过程了。

 

3. 运行ipython和在ipython上运行scrapy shell

在当前的cmd运行框中,因为已经配置了系统环境,是可以直接运行python包的,所以直接在cmd运行框中敲入ipython就会进入到ipython的运行框,跟系统标准的cmd差不多,但是功能更丰富,色彩更丰富,布局也能好。

但是当我直接在这上面敲scrapy shell命令,但是一直说没有此命令,失败。在这里卡住了。

后来通过仔细阅读scrapy shell的说明

If you have IPython installed, the Scrapy shell will use it (instead of the standard Python console). 

意思就是scrapy shell会自己去找ipython的运行框。

于是直接在cmd的标准运行框中输入scrapy shell <url>,返回的结果直接调用到ipython的运行框了。

阅读(887) 评论(0)