Skip to content

Commit

Permalink
txt 格式增加章节标题
Browse files Browse the repository at this point in the history
  • Loading branch information
freeok committed Mar 9, 2024
1 parent 743864c commit b17b0d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
可根据书名、作者搜索并下载小说,命令行操作

可选格式:txt、html

结合 [koodo-reader](https://www.koodoreader.com/zh) 阅读器使用更佳
18 changes: 7 additions & 11 deletions src/main/java/com/pcdd/sonovel/core/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,14 @@ private static void crawlChapter(int chapterNo, String chapterName, String chapt
Document document = Jsoup.parse(new URL(chapterUrl), 10000);
String content = document.getElementById("content").html();

// 去广告内容
content = HtmlUtil.cleanHtmlTag(content)
.replace(" ", " ")
.replace("最新网址:www.xbiqugu.info", "")
.replace("亲,点击进去,给个好评呗,分数越高更新越快,据说给香书小说打满分的最后都找到了漂亮的老婆哦!", "")
.replace("手机站全新改版升级地址:https://wap.xbiqugu.info,数据和书签与电脑站同步,无广告清新阅读!", "");
// 4 空格
content = " " + content.trim();

// html 转 txt
// txt 格式
if ("txt".equals(EXT_NAME)) {
content = HtmlUtil.cleanHtmlTag(content).replace(" ", " ");
content = chapterName + HtmlUtil.cleanHtmlTag(content)
.replace(" ", " ")
// 去除其它内容
.replace("最新网址:www.xbiqugu.info", "")
.replace("亲,点击进去,给个好评呗,分数越高更新越快,据说给香书小说打满分的最后都找到了漂亮的老婆哦!", "")
.replace("手机站全新改版升级地址:https://wap.xbiqugu.info,数据和书签与电脑站同步,无广告清新阅读!", "");
}

download(chapterNo, chapterName, content);
Expand Down

0 comments on commit b17b0d0

Please sign in to comment.