Git Product home page Git Product logo

zhihu-spider's Introduction

#知乎关系网爬虫

DEMO


#使用方法 1、初始化

git clone https://github.com/starkwang/Spider.git && cd Spider

npm run init

2、配置

参考server.config.example.jsspider.config.example.js,配置你自己的server.config.jsspider.config.js

3、构建并开始

npm run build

npm run start // Server runs at localhost:3000

#配置 1、spider.config.js

  • cookie [string](必填项) : 自己在知乎上的cookie
  • _xsrf [string](必填项): 自己在知乎上的_xsrf
  • concurrency [number](可选项): 请求的并发数,默认为3

由于知乎的API较不稳定,concurrency并发数太大可能会造成卡死,在网络环境不好时建议设置为2或者1

2、server.config.js

  • socketPort [number](必填项) : 用于websocket的端口号
  • httpPort [number](必填项): 用于http的端口号

###附:cookie与_xsrf配置方法

打开知乎任意用户的关注者页,例如https://www.zhihu.com/people/starkwei/followers

打开浏览器控制台,选择Network: DEMO

下拉页面,会自动加载更多关注者,可以看到对/node/ProfileFollowersListV2这个接口发起了多次请求: DEMO 打开请求详情,Cookie和_xsrf就在里面: DEMO


#已知的BUG或者缺陷

  1. 对于粉丝数过多的大V,爬取速度过慢
  2. 当相互关注的人中有自己时,不能爬取和自己有关的关系链
  3. 请求失败或者timeout时,没有重发请求,可能会导致部分数据缺失

zhihu-spider's People

Contributors

starkwang avatar dancerphil avatar willian-zhang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.