Python爬虫-PySpider基本操作

2019-08-09  本文已影响0人  坤哥爱卿

PySpider的官方网址:http://docs.pyspider.org/en/latest/

1.安装方法:pip3 install pyspider

安装pyspider之前先安装PhantomJS,参考我的另一篇文章https://www.jianshu.com/p/665d4fa79b4f

安装时会遇到python3.7 与 pyspider 安装问题,参考https://www.jianshu.com/p/618e5ebafb01解决。

命令行调用pyspider all安装控件。

安装成功后,在本地localhost:5000验证。

2.创建项目demo

3.练习网站https://www.tripadvisor.cn/

  pyspider提前css selector非常方便,点击web按钮,图示化操作步骤如下:

  1)点击enable css selector helper按钮

  2)选中要提取内容,提取内容会有红色边框

  3)点击->按钮之后,提取的css selector内容会显示在右边编辑区的光标位置

  4)点击save然后点击run运行,在结果显示区域会返回结果

 5)还可以在编辑区添加on_result方法,获取返回结果并进行数据处理操作

  6)循环调用

7)返回列表调整状态,点击Run运行

关于如何删除项目的方法:

上一篇 下一篇

猜你喜欢

热点阅读