# SeimiCrawler
**Repository Path**: fyname/SeimiCrawler
## Basic Information
- **Project Name**: SeimiCrawler
- **Description**: SeimiCrawler 是一个敏捷的、独立部署的、支持分布式的 Java 爬虫框架,希望能在最大程度上降低新手开发一个可用性高且性能不差的爬虫系统的门槛,以及提升开发爬虫系统的开
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: https://www.oschina.net/p/seimicrawler
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2022-06-19
- **Last Updated**: 2022-06-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
SeimiCrawler
============
[](https://github.com/zhegexiaohuozi/JsoupXpath/releases)
[](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22cn.wanghaomiao%22%20AND%20a%3A%22SeimiCrawler%22)
[](https://opensource.org/licenses/Apache-2.0)
An agile,powerful,standalone,distributed crawler framework.Support spring boot and redisson.
SeimiCrawler的目标是成为Java里最实用的爬虫框架,大家一起加油。
# 简介 #
SeimiCrawler是一个敏捷的,独立部署的,支持分布式的Java爬虫框架,希望能在最大程度上降低新手开发一个可用性高且性能不差的爬虫系统的门槛,以及提升开发爬虫系统的开发效率。在SeimiCrawler的世界里,绝大多数人只需关心去写抓取的业务逻辑就够了,其余的Seimi帮你搞定。设计思想上SeimiCrawler受Python的爬虫框架Scrapy启发,同时融合了Java语言本身特点与Spring的特性,并希望在国内更方便且普遍的使用更有效率的XPath解析HTML,所以SeimiCrawler默认的HTML解析器是[JsoupXpath](http://jsoupxpath.wanghaomiao.cn)(独立扩展项目,非jsoup自带),默认解析提取HTML数据工作均使用XPath来完成(当然,数据处理亦可以自行选择其他解析器)。并结合[SeimiAgent](https://github.com/zhegexiaohuozi/SeimiAgent)彻底完美解决复杂动态页面渲染抓取问题。
# V2.0版本新特性 #
- 完美支持SpringBoot,[demo参考](https://github.com/zhegexiaohuozi/SeimiCrawler/tree/master/spring-boot-example)
- 回调函数支持方法引用,设置起来更自然
```
push(Request.build(s.toString(),Basic::getTitle));
```
- 非SpringBoot模式全局配置项通过`SeimiConfig`进行配置,包括 Redis集群信息,SeimiAgent信息等,SpringBoot模式则通过SpringBoot标准模式配置
```
SeimiConfig config = new SeimiConfig();
config.setSeimiAgentHost("127.0.0.1");
//config.redisSingleServer().setAddress("redis://127.0.0.1:6379");
Seimi s = new Seimi(config);
s.goRun("basic");
```
SpringBoot模式,在application.properties中配置
```
seimi.crawler.enabled=true
# 指定要发起start请求的crawler的name
seimi.crawler.names=basic,test
seimi.crawler.seimi-agent-host=xx
seimi.crawler.seimi-agent-port=xx
#开启分布式队列
seimi.crawler.enable-redisson-queue=true
#自定义bloomFilter预期插入次数,不设置用默认值 ()
#seimi.crawler.bloom-filter-expected-insertions=
#自定义bloomFilter预期的错误率,0.001为1000个允许有一个判断错误的。不设置用默认值(0.001)
#seimi.crawler.bloom-filter-false-probability=
```
- 分布式队列改用Redisson实现,底层依旧为redis,去重引入BloomFilter以提高空间利用率,一个线上的[BloomFilter调参模拟器地址](https://hur.st/bloomfilter/?n=4000&p=1.0E-7&m=&k=8)
- JDK要求 1.8+
# 原理示例 #
## 基本原理 ##

## 集群原理 ##

# 快速开始 #
添加maven依赖(中央maven库最新版本2.1.1):
```
cn.wanghaomiao
SeimiCrawler
2.1.1
```
在包`crawlers`下添加爬虫规则,例如:
```
@Crawler(name = "basic")
public class Basic extends BaseSeimiCrawler {
@Override
public String[] startUrls() {
return new String[]{"http://www.cnblogs.com/"};
}
@Override
public void start(Response response) {
JXDocument doc = response.document();
try {
List