CNode

next-page-kit 爬下一页下一页这种页面的小工具

分享
Mmagicdawn发布于10 年前最后回复10 年前1 回复4568 浏览0 收藏

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)

M
magicdawn#1·10 年前

消灭 0 回复....

参与回复
登录后即可参与回复。登录