From 1534220f0cc46f8fbf4cb606671b2acb9998248b Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Sat, 21 Jun 2025 17:54:59 +0800 Subject: [PATCH] =?UTF-8?q?perf(novel-crawl):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B0=8F=E8=AF=B4=E7=AE=80=E4=BB=8B=E8=BF=87=E6=BB=A4=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/java2nb/novel/core/crawl/CrawlParser.java | 10 ++++++++++ .../java/com/java2nb/novel/core/crawl/RuleBean.java | 1 + .../resources/templates/crawl/crawlSource_add.html | 6 ++++++ .../resources/templates/crawl/crawlSource_update.html | 7 +++++++ 4 files changed, 24 insertions(+) diff --git a/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/CrawlParser.java b/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/CrawlParser.java index e0d5dbc..a50fd19 100644 --- a/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/CrawlParser.java +++ b/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/CrawlParser.java @@ -100,6 +100,16 @@ public class CrawlParser { .replaceAll("

\\s*

", "") .replaceAll("

", "") .replaceAll("

", "
"); + // 小说简介过滤 + String filterDesc = ruleBean.getFilterDesc(); + if (StringUtils.isNotBlank(filterDesc)) { + String[] filterRules = filterDesc.replace("\r\n", "\n").split("\n"); + for (String filterRule : filterRules) { + if (StringUtils.isNotBlank(filterRule)) { + desc = desc.replaceAll(filterRule, ""); + } + } + } //设置书籍简介 book.setBookDesc(desc); if (StringUtils.isNotBlank(ruleBean.getStatusPatten())) { diff --git a/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/RuleBean.java b/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/RuleBean.java index e6f134d..205d785 100644 --- a/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/RuleBean.java +++ b/novel-crawl/src/main/java/com/java2nb/novel/core/crawl/RuleBean.java @@ -45,6 +45,7 @@ public class RuleBean { private String visitCountPatten; private String descStart; private String descEnd; + private String filterDesc; private String upadateTimePatten; private String upadateTimeFormatPatten; private String bookIndexUrl; diff --git a/novel-crawl/src/main/resources/templates/crawl/crawlSource_add.html b/novel-crawl/src/main/resources/templates/crawl/crawlSource_add.html index 4b35329..2c36876 100644 --- a/novel-crawl/src/main/resources/templates/crawl/crawlSource_add.html +++ b/novel-crawl/src/main/resources/templates/crawl/crawlSource_add.html @@ -118,6 +118,9 @@ 示例:</p>
  • + 示例:<span\s+class="allshow">([^/]+)</span> +
  • 示例:更新:(\d+-\d+-\d+\s\d+:\d+:\d+)</a>
  • @@ -338,6 +341,9 @@ crawlRule.descEnd = descEnd; + var filterDesc = $("#filterDesc").val(); + crawlRule.filterDesc = filterDesc; + var upadateTimePatten = $("#upadateTimePatten").val(); if (upadateTimePatten.length > 0) { diff --git a/novel-crawl/src/main/resources/templates/crawl/crawlSource_update.html b/novel-crawl/src/main/resources/templates/crawl/crawlSource_update.html index eec916b..a339fea 100644 --- a/novel-crawl/src/main/resources/templates/crawl/crawlSource_update.html +++ b/novel-crawl/src/main/resources/templates/crawl/crawlSource_update.html @@ -119,6 +119,9 @@ 示例:</p>
  • + 示例:<span\s+class="allshow">([^/]+)</span> +
  • 示例:更新:(\d+-\d+-\d+\s\d+:\d+:\d+)</a>
  • @@ -266,6 +269,7 @@ $("#visitCountPatten").val(crawlRule.visitCountPatten); $("#descStart").val(crawlRule.descStart); $("#descEnd").val(crawlRule.descEnd); + $("#filterDesc").val(crawlRule.filterDesc); $("#upadateTimePatten").val(crawlRule.upadateTimePatten); $("#upadateTimeFormatPatten").val(crawlRule.upadateTimeFormatPatten); $("#bookIndexUrl").val(crawlRule.bookIndexUrl); @@ -424,6 +428,9 @@ crawlRule.descEnd = descEnd; + var filterDesc = $("#filterDesc").val(); + crawlRule.filterDesc = filterDesc; + var upadateTimePatten = $("#upadateTimePatten").val(); if (upadateTimePatten.length > 0) {