Giter Club home page Giter Club logo

web-spider's Introduction

爬虫框架设计

  1. 设计

爬虫生命周期:下载、处理、管理和持久化等功能。 spider控制组件,让它们可以互相交互,流程化的执行。 2. 结构


Download 负责从互联网上下载页面,以便后续处理。 PageProcess 负责解析页面,抽取信息,以及发现新的辅助URL。 SchedulManager 负责管理待抓取的URL,以及一些去重的工作。(jdk队列或者Redis) ResultOutput ResultOutput负责抽取结果的处理,包括计算、持久化到文件、数据库等。 3. 使用


public static void main(String[] args) {
    Spider.create(new GithubProcessor())
            .addUrl("https://github.com/junicore")
            //使用Redis来管理URL队列
            .setScheduler(new RedisScheduler("localhost"))
            //将结果以json方式保存到文件
            .addPipeline(new JsonFilePipeline("D:\\data\\webmagic"))
            //开启5个线程同时执行
            .thread(5)
            //启动爬虫
            .run();
}

一般来说,对于编写一个爬虫,PageProcessor是需要编写的部分,而Spider则是创建和控制爬虫的入口。定制PageProcessr来编写一个爬虫,并通过Spider来启动。

web-spider's People

Contributors

jinhang avatar

Watchers

James Cloos 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.