# garlicts-crawler-spring-boot-starter **Repository Path**: garlicts/garlicts-crawler-spring-boot-starter ## Basic Information - **Project Name**: garlicts-crawler-spring-boot-starter - **Description**: garlicts-crawler单机爬虫的springboot版本 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-01-29 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # garlicts-crawler-spring-boot-starter #### 介绍 garlicts-crawler爬虫框架的springboot版本 #### 软件架构 spring boot starter #### 安装教程 1. clone本项目 2. 安装到本地仓库:mvn clean install #### 使用说明 1. 新建一个springboot项目 2. 添加依赖 ``` com.garlicts garlicts-crawler-spring-boot-starter 1.0.0-SNAPSHOT ``` 3. 修改application.properties配置 ``` com.garlicts.framework.crawler.enabled=true com.garlicts.framework.crawler.crawlerNumber=2 ``` 4. 单元测试 ``` package com.garlicts.demo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlInput; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.garlicts.framework.crawler.CrawlerHttpRequest; import com.garlicts.framework.crawler.CrawlerTemplate; @RunWith(SpringRunner.class) @SpringBootTest public class GarlictsCrawlerSpringBootStarterDemoApplicationTests { @Autowired CrawlerTemplate crawlerTemplate; @Test public void test1() throws Exception { CrawlerHttpRequest crawlerHttpRequest = new CrawlerHttpRequest(); crawlerHttpRequest.setUrl("https://www.baidu.com"); HtmlPage baiduIndexPage = crawlerTemplate.execute(crawlerHttpRequest); HtmlForm htmlForm = baiduIndexPage.getFormByName("f"); HtmlInput baiduWdInput = htmlForm.getInputByName("wd"); baiduWdInput.type("tms运输管理系统"); HtmlInput submitInput = (HtmlInput) baiduIndexPage.getElementById("su"); HtmlPage newHtmlPage = submitInput.click(); System.out.println(newHtmlPage.asText()); newHtmlPage.cleanUp(); baiduIndexPage.cleanUp(); } } ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request