next-page-kit 爬下一页下一页这种页面的小工具
发布于 8 年前 作者 magicdawn 3754 次浏览 来自 分享

RT. 就是下一页, 下一页这种…给抽象了一下… 这里有个抓取 v2ex 的栗子 https://github.com/magicdawn/next-page-kit/blob/v0.0.1/test/simple.js#L16 提供本页要干啥, 是否有下一页, 下一页地址… 最后得到一个结果…就是这样

下面是 README ---------------------------------我是分割线-----------------------------

next-page-kit

Helper for handle next-next page

Build Status Coverage Status npm version npm downloads npm license

Install

npm i next-page-kit -S

API

const NextPage = require('next-page-kit');

n = new NextPage

  • init/postInit : hook function. return a promise is also supported
  • action/hasNext/getNext: the logic
const n = new NextPage({
  init() {

  },
  postInit() {

  },

  action($) {

  },
  hasNext($) {

  },
  getNext($) {

  }
});

yield n.run()

n.run

n.run(url, options)
  • url: the entry
  • options:
    • enc: the html encoding
    • limit: page limit

Changelog

CHANGELOG.md

License

the MIT License http://magicdawn.mit-license.org

1 回复

消灭 0 回复…

回到顶部