美文网首页
puppeteer爬取house365租房数据

puppeteer爬取house365租房数据

作者: ZZES_ZCDC | 来源:发表于2019-03-21 19:39 被阅读0次

很简单, 就是用css选择器扒

1. puppeteer安装依赖

1. 新建项目

$ mkdir house365
$ cd house365
$ npm init
$ npm install puppeteer --save

2. 安装上的相关问题

  • 网络问题
    使用淘宝镜像
$ npm config set registry https://registry.npm.taobao.org
$ npm config set disturl https://npm.taobao.org/dist
$ npm config set puppeteer_download_host https://npm.taobao.org/mirrors
  • windows下node-gyp相关问题
$ npm install -g node-gyp
$ npm install --global --production windows-build-tools

2. 观察

  1. 观察要爬的页面, 最简单的列表型, 我们爬每个的链接


  2. 看分页, 第二页开始一一对应


    image.png
  3. 输入一个比较大的数字, 看看总页数


    image.png
  4. 观察内容页, 这些都用选择器选就是了


    image.png

3.开爬

具体代码: https://github.com/klren0312/puppeteer-study/tree/master/house365

4.结果

image.png image.png

相关文章

网友评论

      本文标题:puppeteer爬取house365租房数据

      本文链接:https://www.haomeiwen.com/subject/txzcvqtx.html