Giter Site home page Giter Site logo

bin-huang / nodespider Goto Github PK

View Code? Open in Web Editor NEW
35.0 4.0 4.0 5.65 MB

[DEPRECATED] Simple, flexible, delightful web crawler/spider package

License: Apache License 2.0

JavaScript 1.69% TypeScript 98.31%
spider crawler web crawl node async promise pipeline

nodespider's Introduction

DEPRECATED / 不再维护

其实这个框架用起来还不错,只是我暂时没有更多兴趣来维护它


NodeSpider 是基于 Nodejs 的新一代爬虫框架。

Feature

  • 开箱即用,用最少的代码开发五脏俱全的爬虫程序
  • 计划规则与任务相分离,再复杂的爬取需求也可以轻松实现
  • 简单好用的数据管道,保存抓取的数据是一件轻松的事情
  • 自动转码 utf8、jQ选择器……可爱的小功能该有的都有
  • 性能优异,你对异步并发有绝对的控制自由
  • 丰富、简约的拓展接口,玩在手里就像灵活的积木
  • 支持现代 promise 和 async function

Install

npm:

npm install nodespider --save

yarn:

yarn add nodespider

Example

const { Spider, jqPlan, csvPipe } = require("nodespider")
const s = new Spider()

// 声明一个数据管道
s.pipe(csvPipe({
  name: "data",
  path: "./data.csv",
  items: ["url", "count"],
}))

// 声明一个爬取计划
s.plan(jqPlan({
  name: "extract",
  toUtf8: true, // 自动转码为 utf8
  retries: 3, // 失败自动重试
  handle: ($, current) => {
    const title = $("title").text() // 你想要的 jq 选择器
    console.log(title)
    s.save("data", {
      count: $("body").text().length,
      url: current.url,
    }) // 使用管道保存数据
    s.addU("extract", $("a").urls())  // 添加新任务
  },
}))

s.add("extract", "https://github.com/Bin-Huang/NodeSpider") // 添加新任务

Document

设置 Options

爬取计划 Plan

数据管道 Pipe

方法 API

事件 Events

与 0.9.x 版本的不同

当前版本几乎是 0.9 的重构,不管是 api 还设计理念,大部分均已改变。如果你的项目依赖 0.9.x 版本,这里保留了 0.9.3 版本文档

Contribute

  • 任何疑问、建议、Bug,欢迎提交 Issuse
  • 分享这个年轻的项目给其他开发者、社区、邮件组
  • 欢迎 Pull Request,尤其是:
    • 翻译文档到其他语言
    • 文档的修改和补充
    • ……

nodespider's People

Contributors

bin-huang avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.