Skip to content

Commit

Permalink
增加爬取小说数据最低分的配置
Browse files Browse the repository at this point in the history
  • Loading branch information
x201206030 committed Nov 12, 2019
1 parent 9f18dd8 commit 587d79c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ Springboot+Mybatis+Mysql+Ehcache+Thymeleaf+Layui

2. 修改项目application.yml配置文件中的数据库配置。

![](./assets/database_config.png)

3. 修改项目application.yml配置文件中的首页本站推荐小说配置(修改的小说需要在数据库中存在)。

![](./assets/index_config.png)

4. 本地直接运行或使用maven插件打包成jar文件上传到服务器上。
4. 根据需求,修改项目application.yml配置文件中的爬取小说最低分配置。

![](./assets/score_config.png)

5. 本地直接运行或使用maven插件打包成jar文件上传到服务器上。

5. `http://ip:port`访问首页。
6. `http://ip:port`访问首页。

6. `http://ip:port/books`访问精品小说模块。
7. `http://ip:port/books`访问精品小说模块。

7. `http://ip:port/book/searchSoftBook.html`访问轻小说模块。
8. `http://ip:port/book/searchSoftBook.html`访问轻小说模块。

#### 项目截图

Expand Down
Binary file added assets/database_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/score_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
Expand Down Expand Up @@ -33,6 +34,9 @@ public class CrawlBooksSchedule {

RestTemplate restTemplate = RestTemplateUtil.getInstance("utf-8");

@Value("${books.lowestScore}")
private Float lowestScore;


private boolean isExcuting = false;

Expand Down Expand Up @@ -485,7 +489,7 @@ private void parseBiquge11Book(Pattern bookPatten, String forObject, int catNum,
try {
Float score = Float.parseFloat(scoreMatch.group(1));

if (score < 8.0) {//数据库空间有效暂时爬取7.5分以上的小说
if (score < lowestScore) {//数据库空间有限,暂时爬取8.0分以上的小说
continue;
}

Expand Down Expand Up @@ -725,7 +729,7 @@ private void parseBook(Pattern bookPatten, String forObject, RestTemplate restTe
try {
Float score = Float.parseFloat(scoreMatch.group(1));

if (score < 8.0) {//数据库空间有效暂时爬取7.5分以上的小说
if (score < lowestScore) {//数据库空间有限,暂时爬取8.0分以上的小说
continue;
}
String bookName = bookNameMatch.group(1);
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ index:
mysql:
charset: utf8mb4


#爬取小说数据的最低评分
books:
lowestScore: 8.0


search:
Expand Down

0 comments on commit 587d79c

Please sign in to comment.