Code Monkey home page Code Monkey logo

scala-akka-crawler's Introduction

基于Scala Akka生产者-消费者模型的爬虫

Build Status GitHub GitHub top language

  • 本项目最初参考了Florian Hopf的akka-crawler-example项目的scala-version:

详细说明:

  • http://blog.florian-hopf.de/2012/08/getting-rid-of-synchronized-using-akka.html

  • https://github.com/fhopf/akka-crawler-example

  • 原项目包含3个简单的Web爬虫程序示例,可执行main方法在cn.edu.jxnu.akka.example中

  • 本项目对引用的组件的版本、语法、过期接口进行了优化处理并解决了已知存在的BUG

  • 本项目为二次开发,接口已经全部重构,仅actor的功能划分沿用了原项目

  • 本项目使用全新的jsoup替换htmlparser

  • 本项目是sbt+SpringBoot项目

本项目代理池参考了fengzhizi715的ProxyPool项目

  • https://github.com/fengzhizi715/ProxyPool
  • 已使用Scala替代

目前主要组件的版本

  • sbt:1.2.8
  • scala:2.11.8
  • lucene:4.7.2
  • akka-actor:2.5.5
  • htmlparser:2.1
  • ikanalyzer:2012_u6
  • jsoup:1.10.3
  • httpclient:4.3.5
  • springboot:1.5.9
  • rxjava2:2.2.3

目前主要功能

  • 支持爬取内容索引
  • 支持抓取时UserAgent随机选取
  • 支持抓取时代理服务器随机选取
  • 支持代理服务器定时更新以及缓存
  • 支持结合SpringBoot开发业务逻辑
  • 支持利用Actor实现分布式抓取、支持重启等策略
  • 支持图片异步下载
  • 支持图片裁剪、存储
  • 支持忽略爬取异常并剔除URL

运行

  1. 简单执行:cn.edu.jxnu.akka.run.FetchInParallelExecution中main方法
  2. 使用SpringBoot执行:cn.edu.jxnu.akka.StartApp中SpringBoot的启动方法
  • 注意
  1. 默认不使用代理,在cn.edu.jxnu.akka.common.Constant可修改
  2. SpringBoot相关配置在application.properties可修改

修改sbt镜像

  1. 找到sbt安装目录下的conf文件夹
  2. 在conf下创建repositories文件
  3. repositories中加入以下内容
[repositories]
local
osc: http://maven.oschina.net/content/groups/public/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-oss-releases
maven-centra
  • 额外(非必须)
  1. IDEA 默认设置中搜sbt,设定最大Max堆1024MB(指定项目默认的sbt内存);
  2. 修改sbtopts文件,增加项 -mem 1024 指定全局sbt的内存;
  3. IDEA 默认启动添加下列虚拟机参数,指定构建配置、sbt根路径以及仓库地址(指定项目默认的构建配置参数);
-Dsbt.log.format=true -Dfile.encoding=UTF8 -Dsbt.boot.directory=D:/sbt -Dsbt.global.base=D:/sbt -Dsbt.ivy.home=D:/sbt -Dsbt.repository.config=D:/sbt/conf/repo.properties

注意:“额外”这里仓库配置是引用了 repo.properties 文件而不是默认的repositories。

示意图

随便画的,能看懂就行

scala-akka-crawler's People

Contributors

jxnu-liguobin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

scala-akka-crawler's Issues

增加URL匹配、优化过滤去重

增加更全的URL匹配、优化过滤去重,优化图片裁剪,压缩存储。解决爬取结束标志。更好的异常全局处理,支持远程actor

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.