Compare commits

...

7 Commits

11 changed files with 40 additions and 27 deletions

View File

@ -54,11 +54,9 @@ Springboot+Mybatis+Mysql+ElasticSearch+Ehcache+Thymeleaf+Layui
3. 搜索页 3. 搜索页
![img](https://gitee.com/xiongxyang/novel-plus/raw/release_v2.1.0/assets/QQ20200520-215756.png)
![img](./assets/QQ20200520-215756.png) ![img](https://oscimg.oschina.net/oscnet/up-ed5f689557718924acac76bc3ebca36afcb.png)
4. 排行榜 4. 排行榜
@ -94,35 +92,27 @@ Springboot+Mybatis+Mysql+ElasticSearch+Ehcache+Thymeleaf+Layui
![img](https://oscimg.oschina.net/oscnet/up-f849960f4c1303fea77d26e64fc505a7180.png) ![img](https://oscimg.oschina.net/oscnet/up-f849960f4c1303fea77d26e64fc505a7180.png)
#### 手机站截图 #### 手机站截图
1. 首页 1. 首页
![index](./assets/QQ%E5%9B%BE%E7%89%8720191018162208.jpg) ![index](https://gitee.com/xiongxyang/novel-plus/raw/release_v2.1.0/assets/QQ%E5%9B%BE%E7%89%8720191018162208.jpg)
2. 小说详情页 2. 小说详情页
![微信图片_20190904181558](./assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190904181558.png) ![微信图片_20190904181558](https://gitee.com/xiongxyang/novel-plus/raw/release_v2.1.0/assets/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190904181558.png)
3. 目录页 3. 目录页
![QQ图片20191018161901](./assets/QQ%E5%9B%BE%E7%89%8720191108022250.png) ![QQ图片20191018161901](https://gitee.com/xiongxyang/novel-plus/raw/release_v2.1.0/assets/QQ%E5%9B%BE%E7%89%8720191108022250.png)
4. 小说阅读页 4. 小说阅读页
![QQ图片20191018161901](./assets/QQ%E5%9B%BE%E7%89%8720191018161901.png) ![QQ图片20191018161901](https://gitee.com/xiongxyang/novel-plus/raw/release_v2.1.0/assets/QQ%E5%9B%BE%E7%89%8720191018161901.png)
#### 爬虫管理系统截图 #### 爬虫管理系统截图
![QQ图片20191018161901](./assets/crawl_index.png) ![img](https://gitee.com/xiongxyang/novel-plus/raw/release_v2.1.2/assets/crawl_index.png)
#### 后台管理系统截图 #### 后台管理系统截图

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>novel</artifactId> <artifactId>novel</artifactId>
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<version>2.1.1</version> <version>2.1.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -10,6 +10,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import javax.imageio.ImageIO;
import java.io.*; import java.io.*;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
@ -48,6 +49,11 @@ public class FileUtil {
out.write(b, 0, n); out.write(b, 0, n);
} }
out.flush();
if( ImageIO.read(picFile) == null){
picSrc = "/images/default.gif";
}
}catch (Exception e){ }catch (Exception e){
log.error(e.getMessage(),e); log.error(e.getMessage(),e);

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>novel</artifactId> <artifactId>novel</artifactId>
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<version>2.1.1</version> <version>2.1.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -30,6 +30,8 @@ import static java.util.regex.Pattern.compile;
@Slf4j @Slf4j
public class CrawlParser { public class CrawlParser {
private static IdWorker idWorker = new IdWorker();
public static final Integer BOOK_INDEX_LIST_KEY = 1; public static final Integer BOOK_INDEX_LIST_KEY = 1;
public static final Integer BOOK_CONTENT_LIST_KEY = 2; public static final Integer BOOK_CONTENT_LIST_KEY = 2;
@ -94,6 +96,8 @@ public class CrawlParser {
String desc = bookDetailHtml.substring(bookDetailHtml.indexOf(ruleBean.getDescStart()) + ruleBean.getDescStart().length()); String desc = bookDetailHtml.substring(bookDetailHtml.indexOf(ruleBean.getDescStart()) + ruleBean.getDescStart().length());
desc = desc.substring(0, desc.indexOf(ruleBean.getDescEnd())); desc = desc.substring(0, desc.indexOf(ruleBean.getDescEnd()));
//过滤掉简介中的a标签
desc = desc.replaceAll("<a[^<]+</a>","");
//设置书籍简介 //设置书籍简介
book.setBookDesc(desc); book.setBookDesc(desc);
if (StringUtils.isNotBlank(ruleBean.getStatusPatten())) { if (StringUtils.isNotBlank(ruleBean.getStatusPatten())) {
@ -173,6 +177,7 @@ public class CrawlParser {
String lastIndexName = null; String lastIndexName = null;
while (isFindIndex) { while (isFindIndex) {
BookIndex hasIndex = hasIndexs.get(indexNum); BookIndex hasIndex = hasIndexs.get(indexNum);
String indexName = indexNameMatch.group(1); String indexName = indexNameMatch.group(1);
@ -199,7 +204,7 @@ public class CrawlParser {
if(hasIndexs.size() == 0){ if(hasIndexs.size() == 0){
//新书入库 //新书入库
//设置目录和章节内容 //设置目录和章节内容
Long indexId = new IdWorker().nextId(); Long indexId = idWorker.nextId();
lastIndexId = indexId; lastIndexId = indexId;
lastIndexName = indexName; lastIndexName = indexName;
bookIndex.setId(indexId); bookIndex.setId(indexId);

View File

@ -167,6 +167,11 @@ public class CrawlServiceImpl implements CrawlService {
boolean isFindBookId = bookIdMatcher.find(); boolean isFindBookId = bookIdMatcher.find();
while (isFindBookId) { while (isFindBookId) {
try { try {
if(Thread.currentThread().isInterrupted()){
return;
}
String bookId = bookIdMatcher.group(1); String bookId = bookIdMatcher.group(1);
Book book = CrawlParser.parseBook(ruleBean, bookId); Book book = CrawlParser.parseBook(ruleBean, bookId);
//这里只做新书入库,查询是否存在这本书 //这里只做新书入库,查询是否存在这本书

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>novel</artifactId> <artifactId>novel</artifactId>
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<version>2.1.1</version> <version>2.1.2</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -179,9 +179,13 @@
for (var i = 0; i < bookList.length; i++) { for (var i = 0; i < bookList.length; i++) {
var book = bookList[i]; var book = bookList[i];
var end = book.bookDesc.indexOf("<"); /*var end = book.bookDesc.indexOf("<");
if(end != -1) { if(end != -1) {
book.bookDesc = book.bookDesc.substring(0,end); book.bookDesc = book.bookDesc.substring(0,end);
}*/
if(book.bookDesc){
book.bookDesc = book.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"").replace(/&nbsp;/g,"");
} }
bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:10px;background: #f2f2f2\">\n" + bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:10px;background: #f2f2f2\">\n" +
@ -202,7 +206,7 @@
" </a>\n" + " </a>\n" +
" <div style=\"margin-top: 5px;color: #4c6978;\">类别:"+book.catName+"</div>\n" + " <div style=\"margin-top: 5px;color: #4c6978;\">类别:"+book.catName+"</div>\n" +
" <div style=\"margin-top: 5px;color: #4c6978;\">状态:"+(book.bookStatus==0?'连载':'完结')+"</div>\n" + " <div style=\"margin-top: 5px;color: #4c6978;\">状态:"+(book.bookStatus==0?'连载':'完结')+"</div>\n" +
" <div style=\"margin-top: 5px;color: #4c6978;\">更新:<i>"+book.lastIndexUpdateTime+"</i>\n" + " <div style=\"margin-top: 5px;color: #4c6978;\">更新:<i>"+book.lastIndexUpdateTime.substr(0,11)+"</i>\n" +
" </div>\n" + " </div>\n" +
" <div style=\"margin-top: 5px;color: #4c6978;\">简介:"+(book.bookDesc?(book.bookDesc.length>20?(book.bookDesc.substr(0,20)+"..."):book.bookDesc):book.bookDesc)+"</div>\n" + " <div style=\"margin-top: 5px;color: #4c6978;\">简介:"+(book.bookDesc?(book.bookDesc.length>20?(book.bookDesc.substr(0,20)+"..."):book.bookDesc):book.bookDesc)+"</div>\n" +
"\n" + "\n" +

View File

@ -276,6 +276,10 @@
for (var i = 0; i < 6; i++) { for (var i = 0; i < 6; i++) {
var hotRecBook = hotRecBooks[i]; var hotRecBook = hotRecBooks[i];
if(hotRecBook.bookDesc){
hotRecBook.bookDesc = hotRecBook.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"");
}
hotRecBooksHtml += ("<div style=\"margin-bottom: 5px\" class=\"layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4\">\n" + hotRecBooksHtml += ("<div style=\"margin-bottom: 5px\" class=\"layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4\">\n" +
" <a href=\"/book/"+hotRecBook.bookId+".html\">\n" + " <a href=\"/book/"+hotRecBook.bookId+".html\">\n" +
" <div class=\"layui-col-xs5 layui-col-sm4 layui-col-md4 layui-col-lg4\" >\n" + " <div class=\"layui-col-xs5 layui-col-sm4 layui-col-md4 layui-col-lg4\" >\n" +
@ -323,9 +327,8 @@
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var updateRankBook = updateRankBooks[i]; var updateRankBook = updateRankBooks[i];
var end = updateRankBook.bookDesc.indexOf("<"); if(updateRankBook.bookDesc){
if(end != -1) { updateRankBook.bookDesc = updateRankBook.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"");
updateRankBook.bookDesc = updateRankBook.bookDesc.substring(0,end);
} }
updateRankBookHtml += ("<div style=\"padding-bottom: 30px\"\n" + updateRankBookHtml += ("<div style=\"padding-bottom: 30px\"\n" +

View File

@ -5,7 +5,7 @@
<groupId>com.java2nb</groupId> <groupId>com.java2nb</groupId>
<artifactId>novel</artifactId> <artifactId>novel</artifactId>
<version>2.1.1</version> <version>2.1.2</version>
<modules> <modules>
<module>novel-common</module> <module>novel-common</module>
<module>novel-front</module> <module>novel-front</module>