{"id":13464556,"url":"https://github.com/zhegexiaohuozi/SeimiCrawler","last_synced_at":"2025-03-25T11:31:43.890Z","repository":{"id":2092278,"uuid":"45692123","full_name":"zhegexiaohuozi/SeimiCrawler","owner":"zhegexiaohuozi","description":"一个简单、敏捷、分布式的支持SpringBoot的Java爬虫框架;An agile, distributed crawler framework.","archived":false,"fork":false,"pushed_at":"2024-11-25T08:37:36.000Z","size":553,"stargazers_count":1984,"open_issues_count":31,"forks_count":680,"subscribers_count":176,"default_branch":"master","last_synced_at":"2025-03-22T20:01:44.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://seimicrawler.org","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhegexiaohuozi.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-06T16:06:36.000Z","updated_at":"2025-03-21T06:07:16.000Z","dependencies_parsed_at":"2023-01-13T11:37:31.482Z","dependency_job_id":"f6d46560-92f3-4e83-8a48-f936ae6223b9","html_url":"https://github.com/zhegexiaohuozi/SeimiCrawler","commit_stats":{"total_commits":229,"total_committers":7,"mean_commits":"32.714285714285715","dds":0.07423580786026196,"last_synced_commit":"c971b64d7efdb9ce6b0c2ff42a7a4f7bdb13e770"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhegexiaohuozi%2FSeimiCrawler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhegexiaohuozi%2FSeimiCrawler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhegexiaohuozi%2FSeimiCrawler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhegexiaohuozi%2FSeimiCrawler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhegexiaohuozi","download_url":"https://codeload.github.com/zhegexiaohuozi/SeimiCrawler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245454026,"owners_count":20617965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T14:00:46.207Z","updated_at":"2025-03-25T11:31:43.881Z","avatar_url":"https://github.com/zhegexiaohuozi.png","language":"Java","funding_links":[],"categories":["All","Java","Java (504)"],"sub_categories":[],"readme":"SeimiCrawler\n============\n[![GitHub release](https://img.shields.io/github/release/zhegexiaohuozi/SeimiCrawler.svg)](https://github.com/zhegexiaohuozi/JsoupXpath/releases)\n[![Maven](https://maven-badges.herokuapp.com/maven-central/cn.wanghaomiao/SeimiCrawler/badge.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22cn.wanghaomiao%22%20AND%20a%3A%22SeimiCrawler%22)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nAn agile,powerful,standalone,distributed crawler framework.Support spring boot and redisson.\n\nSeimiCrawler的目标是成为Java里最实用的爬虫框架，大家一起加油。\n\nIf you like this project, please give it a Star.\nRead detail in [English](docs/English.md) | [日本語](docs/Japanese.md) | [한국어](docs/Korean.md) | [Русский](docs/Russian.md) | [Français](docs/Franch.md) | [Deutsch](docs/German.md) | [Italiano](docs/Italian.md) | [Español](docs/Spanish.md).\n\n# 简介 #\n\nSeimiCrawler是一个敏捷的，独立部署的，支持分布式的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)彻底完美解决复杂动态页面渲染抓取问题。\n\n# 最新进展、资讯订阅 #\n\n- 微信订阅号\n\n![weixin](http://img.wanghaomiao.cn/seimiweixin_v2.jpeg)\n\n里面会发布一些使用案例等文章，以及seimi体系相关项目的最新更新动态，后端技术，研发感悟等等。\n\n# V2.0版本新特性 #\n\n- 完美支持SpringBoot，[demo参考](https://github.com/zhegexiaohuozi/SeimiCrawler/tree/master/spring-boot-example)\n\n- 回调函数支持方法引用，设置起来更自然\n\n```\n    push(Request.build(s.toString(),Basic::getTitle));\n\n```\n\n- 非SpringBoot模式全局配置项通过`SeimiConfig`进行配置，包括 Redis集群信息，SeimiAgent信息等，SpringBoot模式则通过SpringBoot标准模式配置\n\n```\nSeimiConfig config = new SeimiConfig();\nconfig.setSeimiAgentHost(\"127.0.0.1\");\n//config.redisSingleServer().setAddress(\"redis://127.0.0.1:6379\");\nSeimi s = new Seimi(config);\ns.goRun(\"basic\");\n```\n\nSpringBoot模式，在application.properties中配置\n\n```\nseimi.crawler.enabled=true\n# 指定要发起start请求的crawler的name\nseimi.crawler.names=basic,test\n\nseimi.crawler.seimi-agent-host=xx\nseimi.crawler.seimi-agent-port=xx\n\n#开启分布式队列\nseimi.crawler.enable-redisson-queue=true\n#自定义bloomFilter预期插入次数，不设置用默认值 （）\n#seimi.crawler.bloom-filter-expected-insertions=\n#自定义bloomFilter预期的错误率，0.001为1000个允许有一个判断错误的。不设置用默认值（0.001）\n#seimi.crawler.bloom-filter-false-probability=\n```\n\n- 分布式队列改用Redisson实现，底层依旧为redis，去重引入BloomFilter以提高空间利用率，一个线上的[BloomFilter调参模拟器地址](https://hur.st/bloomfilter/?n=4000\u0026p=1.0E-7\u0026m=\u0026k=8)\n\n- JDK要求 1.8+\n\n\n# 原理示例 #\n## 基本原理 ##\n![SeimiCrawler原理图](http://img.wanghaomiao.cn/v2_Seimi.png)\n\n## 集群原理 ##\n![SeimiCrawler集群原理图](http://img.wanghaomiao.cn/v1_distributed.png)\n\n# 社区沟通讨论 #\n\n- QQ群:`557410934`\n\n![QQ群](http://img.wanghaomiao.cn/seimiqq.png)\n\n这个就是给大家自由沟通啦\n\n\n# 快速开始 #\n\n添加maven依赖(以中央maven库最新版本为准，下仅供参考)：\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ecn.wanghaomiao\u003c/groupId\u003e\n    \u003cartifactId\u003eSeimiCrawler\u003c/artifactId\u003e\n    \u003cversion\u003e2.1.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n在包`crawlers`下添加爬虫规则，例如：\n```\n@Crawler(name = \"basic\")\npublic class Basic extends BaseSeimiCrawler {\n    @Override\n    public String[] startUrls() {\n        return new String[]{\"http://www.cnblogs.com/\"};\n    }\n     @Override\n     public void start(Response response) {\n         JXDocument doc = response.document();\n         try {\n             List\u003cObject\u003e urls = doc.sel(\"//a[@class='titlelnk']/@href\");\n             logger.info(\"{}\", urls.size());\n             for (Object s:urls){\n                 push(Request.build(s.toString(),Basic::getTitle));\n             }\n         } catch (Exception e) {\n             e.printStackTrace();\n         }\n     }\n     public void getTitle(Response response){\n         JXDocument doc = response.document();\n         try {\n             logger.info(\"url:{} {}\", response.getUrl(), doc.sel(\"//h1[@class='postTitle']/a/text()|//a[@id='cb_post_title_url']/text()\"));\n             //do something\n         } catch (Exception e) {\n             e.printStackTrace();\n         }\n     }\n}\n```\n然后随便某个包下添加启动Main函数，启动SeimiCrawler：\n```\npublic class Boot {\n    public static void main(String[] args){\n        Seimi s = new Seimi();\n        s.start(\"basic\");\n    }\n}\n```\n以上便是一个最简单的爬虫系统开发流程。\n\n## 工程化打包部署 ##\n\n### Spring boot(推荐) ###\n推荐使用spring boot方式来构建项目，这样能借助现有的spring boot生态扩展出很多意想不到的玩法。Spring boot项目打包参考spring boot官网的标准打包方式即可\n```\nmvn package\n```\n\n### 独立运行 ###\n上面可以方便的用来开发或是调试，当然也可以成为生产环境下一种启动方式。但是，为了便于工程化部署与分发，SeimiCrawler提供了专门的打包插件用来对SeimiCrawler工程进行打包，打好的包可以直接分发部署运行了。\n\npom中添加添加plugin\n```\n\u003cplugin\u003e\n    \u003cgroupId\u003ecn.wanghaomiao\u003c/groupId\u003e\n    \u003cartifactId\u003emaven-seimicrawler-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e1.2.0\u003c/version\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cphase\u003epackage\u003c/phase\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003ebuild\u003c/goal\u003e\n            \u003c/goals\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n    \u003c!--\u003cconfiguration\u003e--\u003e\n        \u003c!-- 默认target目录 --\u003e\n        \u003c!--\u003coutputDirectory\u003e/some/path\u003c/outputDirectory\u003e--\u003e\n    \u003c!--\u003c/configuration\u003e--\u003e\n\u003c/plugin\u003e\n```\n执行`mvn clean package`即可，打好包目录结构如下：\n```\n.\n├── bin             # 相应的脚本中也有具体启动参数说明介绍，在此不再敖述\n│   ├── run.bat    #windows下启动脚本\n│   └── run.sh     #Linux下启动脚本\n└── seimi\n    ├── classes     #Crawler工程业务类及相关配置文件目录\n    └── lib         #工程依赖包目录\n```\n接下来就可以直接用来分发与部署了。\n\n\u003e 详细请继续参阅[maven-seimicrawler-plugin](https://github.com/zhegexiaohuozi/maven-seimicrawler-plugin)\n\n# 更多文档 #\n\n目前可以参考demo工程中的样例，基本包含了主要的特性用法。更为细致的文档移步[SeimiCrawler主页](http://seimi.wanghaomiao.cn)中进一步查看\n\n\n# Change log #\n\n请参阅 [ChangeLog.md](https://github.com/zhegexiaohuozi/SeimiCrawler/blob/master/ChangeLog.md)\n\n# 项目源码 #\n[Github](https://github.com/zhegexiaohuozi/SeimiCrawler)\n\u003e **BTW:**\n\u003e 如果您觉着这个项目不错，到github上`star`一下，我是不介意的 ^_^\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhegexiaohuozi%2FSeimiCrawler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhegexiaohuozi%2FSeimiCrawler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhegexiaohuozi%2FSeimiCrawler/lists"}