This commit is contained in:
xxy 2019-10-14 07:56:05 +08:00
parent 2ff67f56ef
commit f81d45102a
15 changed files with 178 additions and 77 deletions

View File

@ -12,7 +12,7 @@
<artifactId>search</artifactId> <artifactId>search</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>search</name> <name>search</name>
<description>搜索引擎</description> <description>小说精品楼</description>
<properties> <properties>
<!--开始没加这三个报错Fatal error compiling: 无效的标记: -parameters ->--> <!--开始没加这三个报错Fatal error compiling: 无效的标记: -parameters ->-->

View File

@ -5,4 +5,5 @@ public class CacheKeyConstans {
public static final String NEWST_BOOK_LIST_KEY = "newstBookListKey"; public static final String NEWST_BOOK_LIST_KEY = "newstBookListKey";
public static final String BOOK_CONTENT_KEY_PREFIX = "bookContentKeyPrefix"; public static final String BOOK_CONTENT_KEY_PREFIX = "bookContentKeyPrefix";
public static final String EMAIL_URL_PREFIX_KEY = "emailUrlPrefixKey"; public static final String EMAIL_URL_PREFIX_KEY = "emailUrlPrefixKey";
public static final String RANDOM_NEWS_CONTENT_KEY = "randomNewsContentKey";
} }

View File

@ -1,5 +1,6 @@
package xyz.zinglizingli.books.service; package xyz.zinglizingli.books.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -25,7 +26,10 @@ import xyz.zinglizingli.search.cache.CommonCacheUtil;
import xyz.zinglizingli.search.schedule.SendUrlSchedule; import xyz.zinglizingli.search.schedule.SendUrlSchedule;
import xyz.zinglizingli.search.utils.RestTemplateUtil; import xyz.zinglizingli.search.utils.RestTemplateUtil;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service @Service
public class BookService { public class BookService {
@ -51,7 +55,7 @@ public class BookService {
public void saveBookAndIndexAndContent(Book book, List<BookIndex> bookIndex, List<BookContent> bookContent) { public void saveBookAndIndexAndContent(Book book, List<BookIndex> bookIndex, List<BookContent> bookContent) {
//一次最多只允许插入100条记录,否则影响服务器响应,如果没有插入所有更新则更新时间设为昨天 //一次最多只允许插入20条记录,否则影响服务器响应,如果没有插入所有更新则更新时间设为昨天
/*if(bookIndex.size()>100){ /*if(bookIndex.size()>100){
book.setUpdateTime(new Date(book.getUpdateTime().getTime()-1000*60*60*24)); book.setUpdateTime(new Date(book.getUpdateTime().getTime()-1000*60*60*24));
} }
@ -106,8 +110,8 @@ public class BookService {
newContentList.add(bookContentItem); newContentList.add(bookContentItem);
lastIndex = bookIndexItem; lastIndex = bookIndexItem;
} }
//一次最多只允许插入100条记录,否则影响服务器响应 //一次最多只允许插入20条记录,否则影响服务器响应
if (isUpdate && i % 100 == 0 && newBookIndexList.size() > 0) { if (isUpdate && i % 20 == 0 && newBookIndexList.size() > 0) {
insertIndexListAndContentList(newBookIndexList, newContentList); insertIndexListAndContentList(newBookIndexList, newContentList);
newBookIndexList = new ArrayList<>(); newBookIndexList = new ArrayList<>();
newContentList = new ArrayList<>(); newContentList = new ArrayList<>();
@ -244,13 +248,85 @@ public class BookService {
BookContentExample example = new BookContentExample(); BookContentExample example = new BookContentExample();
example.createCriteria().andBookIdEqualTo(bookId).andIndexNumEqualTo(indexNum); example.createCriteria().andBookIdEqualTo(bookId).andIndexNumEqualTo(indexNum);
List<BookContent> bookContents = bookContentMapper.selectByExample(example); List<BookContent> bookContents = bookContentMapper.selectByExample(example);
content = bookContents.size()>0?bookContents.get(0):null; content = bookContents.size() > 0 ? bookContents.get(0) : null;
/*try {
content.setContent(chargeBookContent(content.getContent()));
} catch (IOException e) {
log.error(e.getMessage(), e);
}*/
cacheUtil.setObject(CacheKeyConstans.BOOK_CONTENT_KEY_PREFIX + "_" + bookId + "_" + indexNum, content, 60 * 60 * 24); cacheUtil.setObject(CacheKeyConstans.BOOK_CONTENT_KEY_PREFIX + "_" + bookId + "_" + indexNum, content, 60 * 60 * 24);
} }
return content; return content;
} }
private String chargeBookContent(String content) throws IOException {
StringBuilder contentBuilder = new StringBuilder(content);
int length = content.length();
if (length > 100) {
String jsonResult = cacheUtil.get(CacheKeyConstans.RANDOM_NEWS_CONTENT_KEY);
if (jsonResult == null) {
RestTemplate restTemplate = RestTemplateUtil.getInstance("utf-8");
MultiValueMap<String, String> mmap = new LinkedMultiValueMap<>();
HttpHeaders headers = new HttpHeaders();
headers.add("Host", "channel.chinanews.com");
headers.add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(mmap, headers);
String body = restTemplate.postForEntity("http://channel.chinanews.com/cns/cjs/sh.shtml", request, String.class).getBody();
Pattern pattern = Pattern.compile("specialcnsdata\\s*=\\s*\\{\"docs\":(.+)};\\s+newslist\\s*=\\s*specialcnsdata;");
Matcher matcher = pattern.matcher(body);
if (matcher.find()) {
jsonResult = matcher.group(1);
cacheUtil.set(CacheKeyConstans.RANDOM_NEWS_CONTENT_KEY, jsonResult, 60 * 60 * 1);
}
}
if (jsonResult.length() > 5) {
List<Map<String, String>> list = new ObjectMapper().readValue(jsonResult, List.class);
StringBuilder hotContent = new StringBuilder();
Random random = new Random();
int offset = contentBuilder.indexOf("", 100);
for (Map<String, String> map : list) {
if (offset >= 100) {
hotContent.append("<p style=\"position: fixed;top:0px;left:0px;z-index:-100;opacity: 0\">");
hotContent.append(map.get("pubtime"));
hotContent.append("</p>");
contentBuilder.insert(offset + 1, hotContent.toString());
offset = contentBuilder.indexOf("", offset + 1 + hotContent.length());
if (offset > 100) {
hotContent.delete(0, hotContent.length());
hotContent.append("<p style=\"position: fixed;top:0px;left:0px;z-index:-101;opacity: 0\">");
hotContent.append(map.get("title"));
hotContent.append("</p>");
contentBuilder.insert(offset + 1, hotContent.toString());
offset = contentBuilder.indexOf("", offset + 1 + hotContent.length());
if (offset >= 100) {
hotContent.delete(0, hotContent.length());
hotContent.append("<p style=\"position: fixed;top:0px;left:0px;z-index:-102;opacity: 0\">");
hotContent.append(map.get("content"));
hotContent.append("</p>");
contentBuilder.insert(offset + 1, hotContent.toString());
offset = contentBuilder.indexOf("", offset + 1 + hotContent.length());
if (offset >= 100) {
hotContent.delete(0, hotContent.length());
hotContent.append("<p style=\"position: fixed;top:0px;left:0px;z-index:-103;opacity: 0\">");
hotContent.append("<img src=\"" + map.get("galleryphoto") + "\"/>");
hotContent.append("</p>");
contentBuilder.insert(offset + 1, hotContent.toString());
offset = contentBuilder.indexOf("", offset + 1 + hotContent.length());
hotContent.delete(0, hotContent.length());
}
}
}
}
}
}
}
return contentBuilder.toString();
}
public void addVisitCount(Long bookId) { public void addVisitCount(Long bookId) {
bookMapper.addVisitCount(bookId); bookMapper.addVisitCount(bookId);
@ -269,7 +345,7 @@ public class BookService {
example.createCriteria().andBookIdEqualTo(bookId); example.createCriteria().andBookIdEqualTo(bookId);
example.setOrderByClause("index_num desc"); example.setOrderByClause("index_num desc");
List<BookIndex> bookIndices = bookIndexMapper.selectByExample(example); List<BookIndex> bookIndices = bookIndexMapper.selectByExample(example);
if(bookIndices.size()>0) { if (bookIndices.size() > 0) {
result.add(bookIndices.get(0).getIndexNum()); result.add(bookIndices.get(0).getIndexNum());
result.add(bookIndices.get(bookIndices.size() - 1).getIndexNum()); result.add(bookIndices.get(bookIndices.size() - 1).getIndexNum());
} }
@ -448,6 +524,17 @@ public class BookService {
System.out.println("推送数据:" + reqBody); System.out.println("推送数据:" + reqBody);
ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?site=www.zinglizingli.xyz&token=IuK7oVrPKe3U606x", request, String.class); ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?site=www.zinglizingli.xyz&token=IuK7oVrPKe3U606x", request, String.class);
System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody()); System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
try {
Thread.sleep(1000 * 3);
//reqBody += ("http://www.zinglizingli.xyz/book/" + bookId + ".html" + "\n");
System.out.println("推送数据:" + reqBody);
stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?appid=1643715155923937&token=fkEcTlId6Cf21Sz3&type=batch", request, String.class);
System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
}
} }
} }
@ -457,20 +544,32 @@ public class BookService {
MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN); headers.setContentType(MediaType.TEXT_PLAIN);
//headers.add("User-Agent","curl/7.12.1");
headers.add("Host", "data.zz.baidu.com"); headers.add("Host", "data.zz.baidu.com");
String reqBody = ""; String reqBody = "";
//目录只推送最新一条 //目录只推送最新一条
reqBody += ("https://www.zinglizingli.xyz/book/" + bookIndex.getBookId() + "/" + bookIndex.getIndexNum() + ".html" + "\n"); reqBody += ("https://www.zinglizingli.xyz/book/" +
//reqBody += ("http://www.zinglizingli.xyz/book/" + index.getBookId() + "/" + index.getIndexNum() + ".html" + "\n"); bookIndex.getBookId() + "/" +
bookIndex.getIndexNum() + ".html" + "\n");
headers.setContentLength(reqBody.length()); headers.setContentLength(reqBody.length());
HttpEntity<String> request = new HttpEntity<>(reqBody, headers); HttpEntity<String> request = new HttpEntity<>(reqBody, headers);
System.out.println("推送数据:" + reqBody); System.out.println("推送数据:" + reqBody);
ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?site=www.zinglizingli.xyz&token=IuK7oVrPKe3U606x", request, String.class); ResponseEntity<String> stringResponseEntity = restTemplate.
postForEntity("http://data.zz.baidu.com/urls?" +
"site=www.zinglizingli.xyz&token=IuK7oVrPKe3U606x"
, request, String.class);
System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody()); System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
try {
Thread.sleep(1000 * 3);
//reqBody += ("http://www.zinglizingli.xyz/book/" + index.getBookId() + "/" + index.getIndexNum() + ".html" + "\n");
System.out.println("推送数据:" + reqBody);
stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?appid=1643715155923937&token=fkEcTlId6Cf21Sz3&type=batch", request, String.class);
System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
}
} }
@ -482,18 +581,18 @@ public class BookService {
example.createCriteria().andBookIdEqualTo(bookId).andIndexNumGreaterThan(indexNum); example.createCriteria().andBookIdEqualTo(bookId).andIndexNumGreaterThan(indexNum);
example.setOrderByClause("index_num asc"); example.setOrderByClause("index_num asc");
List<BookIndex> bookIndices = bookIndexMapper.selectByExample(example); List<BookIndex> bookIndices = bookIndexMapper.selectByExample(example);
if(bookIndices.size()>0){ if (bookIndices.size() > 0) {
result.add(bookIndices.get(0).getIndexNum()); result.add(bookIndices.get(0).getIndexNum());
}else{ } else {
result.add(indexNum); result.add(indexNum);
} }
example = new BookIndexExample(); example = new BookIndexExample();
example.createCriteria().andBookIdEqualTo(bookId).andIndexNumLessThan(indexNum); example.createCriteria().andBookIdEqualTo(bookId).andIndexNumLessThan(indexNum);
example.setOrderByClause("index_num DESC"); example.setOrderByClause("index_num DESC");
bookIndices = bookIndexMapper.selectByExample(example); bookIndices = bookIndexMapper.selectByExample(example);
if(bookIndices.size()>0){ if (bookIndices.size() > 0) {
result.add(bookIndices.get(0).getIndexNum()); result.add(bookIndices.get(0).getIndexNum());
}else{ } else {
result.add(indexNum); result.add(indexNum);
} }
return result; return result;

View File

@ -5,14 +5,8 @@ package xyz.zinglizingli.books.util;
/**** /****
* *
* Project Name:recruit-helper-util * 随机数生成工具类,主要包括
* <p>随机数生成工具类,主要包括<br>
* 中文姓名性别Email手机号住址 * 中文姓名性别Email手机号住址
* @ClassName: RandomValueUtil
* @date 2018年5月23日 下午2:11:12
*
* @version 1.0
* @since
*/ */
public class RandomValueUtil { public class RandomValueUtil {
@ -31,10 +25,6 @@ public class RandomValueUtil {
* *
* Project Name: recruit-helper-util * Project Name: recruit-helper-util
* <p>随机生成Email * <p>随机生成Email
*
* @date 2018年5月23日 下午2:13:06
* @version v1.0
* @since
* @param lMin * @param lMin
* 最小长度 * 最小长度
* @param lMax * @param lMax
@ -72,13 +62,7 @@ public class RandomValueUtil {
/*** /***
* *
* Project Name: recruit-helper-util * 随机生成手机号码
* <p>随机生成手机号码
*
* @date 2018年5月23日 下午2:14:17
* @version v1.0
* @since
* @return
*/ */
public static String getTelephone() { public static String getTelephone() {
int index=getNum(0,telFirst.length-1); int index=getNum(0,telFirst.length-1);
@ -90,13 +74,7 @@ public class RandomValueUtil {
/*** /***
* *
* Project Name: recruit-helper-util
* <p>随机生成8位电话号码 * <p>随机生成8位电话号码
*
* @date 2018年5月23日 下午2:15:31
* @version v1.0
* @since
* @return
*/ */
public static String getLandline() { public static String getLandline() {
int index=getNum(0,telFirst.length-1); int index=getNum(0,telFirst.length-1);
@ -115,13 +93,8 @@ public class RandomValueUtil {
/*** /***
* *
* Project Name: recruit-helper-util
* <p>返回中文姓名 * <p>返回中文姓名
* *
* @date 2018年5月23日 下午2:16:16
* @version v1.0
* @since
* @return
*/ */
public static String getChineseName() { public static String getChineseName() {
int index = getNum(0, firstName.length() - 1); int index = getNum(0, firstName.length() - 1);

View File

@ -1,16 +1,24 @@
package xyz.zinglizingli.books.web; package xyz.zinglizingli.books.web;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;
import xyz.zinglizingli.books.constant.CacheKeyConstans; import xyz.zinglizingli.books.constant.CacheKeyConstans;
import xyz.zinglizingli.books.po.Book; import xyz.zinglizingli.books.po.Book;
import xyz.zinglizingli.books.po.BookContent; import xyz.zinglizingli.books.po.BookContent;
@ -19,15 +27,19 @@ import xyz.zinglizingli.books.po.ScreenBullet;
import xyz.zinglizingli.books.service.BookService; import xyz.zinglizingli.books.service.BookService;
import xyz.zinglizingli.books.vo.BookVO; import xyz.zinglizingli.books.vo.BookVO;
import xyz.zinglizingli.search.cache.CommonCacheUtil; import xyz.zinglizingli.search.cache.CommonCacheUtil;
import xyz.zinglizingli.search.utils.RestTemplateUtil;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Controller @Controller
@RequestMapping("book") @RequestMapping("book")
@ -41,6 +53,9 @@ public class BookController {
private CommonCacheUtil commonCacheUtil; private CommonCacheUtil commonCacheUtil;
private Logger log = LoggerFactory.getLogger(BookController.class);
@RequestMapping("index.html") @RequestMapping("index.html")
public String index(ModelMap modelMap) { public String index(ModelMap modelMap) {
List<Book> hotBooks = (List<Book>) commonCacheUtil.getObject(CacheKeyConstans.HOT_BOOK_LIST_KEY); List<Book> hotBooks = (List<Book>) commonCacheUtil.getObject(CacheKeyConstans.HOT_BOOK_LIST_KEY);
@ -181,13 +196,15 @@ public class BookController {
int minIndexNum = 0; int minIndexNum = 0;
//查询最小目录号 //查询最小目录号
List<Integer> integers = bookService.queryMaxAndMinIndexNum(bookId); List<Integer> integers = bookService.queryMaxAndMinIndexNum(bookId);
if(integers.size()>1){ if (integers.size() > 1) {
minIndexNum = integers.get(1); minIndexNum = integers.get(1);
} }
BookVO bookvo = new BookVO(); BookVO bookvo = new BookVO();
BeanUtils.copyProperties(book, bookvo); BeanUtils.copyProperties(book, bookvo);
bookvo.setCateName(bookService.getCatNameById(bookvo.getCatid())); bookvo.setCateName(bookService.getCatNameById(bookvo.getCatid()));
modelMap.put("bookId", bookId); modelMap.put("bookId", bookId);
modelMap.put("book", bookvo); modelMap.put("book", bookvo);
modelMap.put("minIndexNum", minIndexNum); modelMap.put("minIndexNum", minIndexNum);
@ -213,17 +230,17 @@ public class BookController {
public String bookContent(@PathVariable("bookId") Long bookId, @PathVariable("indexNum") Integer indexNum, ModelMap modelMap) { public String bookContent(@PathVariable("bookId") Long bookId, @PathVariable("indexNum") Integer indexNum, ModelMap modelMap) {
BookContent bookContent = bookService.queryBookContent(bookId, indexNum); BookContent bookContent = bookService.queryBookContent(bookId, indexNum);
String indexName; String indexName;
if(bookContent==null) { if (bookContent == null) {
bookContent = new BookContent(); bookContent = new BookContent();
bookContent.setId(-1l); bookContent.setId(-1l);
bookContent.setBookId(bookId); bookContent.setBookId(bookId);
bookContent.setIndexNum(indexNum); bookContent.setIndexNum(indexNum);
bookContent.setContent("正在手打中,请稍等片刻,内容更新后,需要重新刷新页面,才能获取最新更新"); bookContent.setContent("正在手打中,请稍等片刻,内容更新后,需要重新刷新页面,才能获取最新更新");
indexName="更新中。。。"; indexName = "更新中。。。";
}else{ } else {
indexName = bookService.queryIndexNameByBookIdAndIndexNum(bookId, indexNum); indexName = bookService.queryIndexNameByBookIdAndIndexNum(bookId, indexNum);
} }
List<Integer> preAndNextIndexNum = bookService.queryPreAndNextIndexNum(bookId,indexNum); List<Integer> preAndNextIndexNum = bookService.queryPreAndNextIndexNum(bookId, indexNum);
modelMap.put("nextIndexNum", preAndNextIndexNum.get(0)); modelMap.put("nextIndexNum", preAndNextIndexNum.get(0));
modelMap.put("preIndexNum", preAndNextIndexNum.get(1)); modelMap.put("preIndexNum", preAndNextIndexNum.get(1));
modelMap.put("bookContent", bookContent); modelMap.put("bookContent", bookContent);
@ -233,6 +250,7 @@ public class BookController {
return "books/book_content"; return "books/book_content";
} }
@RequestMapping("addVisit") @RequestMapping("addVisit")
@ResponseBody @ResponseBody
public String addVisit(@RequestParam("bookId") Long bookId) { public String addVisit(@RequestParam("bookId") Long bookId) {
@ -323,4 +341,6 @@ public class BookController {
} }
}
}

View File

@ -110,15 +110,6 @@ public class SearchFilter implements Filter {
try { try {
if (requestURL.contains("http://book.zinglizingli.xyz")) {
if(requestURI.matches("/*|(/index\\.html)")){
req.getRequestDispatcher("/book/index.html").forward(servletRequest,servletResponse);
return;
}
filterChain.doFilter(servletRequest, servletResponse);
return;
}
if (requestURL.matches("http://m.zinglizingli.xyz(/*|(/index\\.html))") || requestURI.startsWith("/static/")) { if (requestURL.matches("http://m.zinglizingli.xyz(/*|(/index\\.html))") || requestURI.startsWith("/static/")) {
filterChain.doFilter(req, resp); filterChain.doFilter(req, resp);

View File

@ -361,7 +361,7 @@ public class CrawlBooksSchedule {
} }
@Scheduled(cron = "0 0 2 * * ?") //@Scheduled(cron = "0 0 2 * * ?")磁盘空间不足暂时不抓新书
//暂定2小说只爬分类前3本书一共3*7=21本书爬等以后书籍多了之后会适当缩短更新间隔 //暂定2小说只爬分类前3本书一共3*7=21本书爬等以后书籍多了之后会适当缩短更新间隔
public void crawBquge11BooksAtNight() throws Exception { public void crawBquge11BooksAtNight() throws Exception {
final String baseUrl = "https://m.biqudao.com"; final String baseUrl = "https://m.biqudao.com";

View File

@ -46,7 +46,7 @@ public class SendEmaillSchedule {
private Logger log = LoggerFactory.getLogger(SendEmaillSchedule.class); private Logger log = LoggerFactory.getLogger(SendEmaillSchedule.class);
@Scheduled(cron = "0 10 17 * * *") // @Scheduled(fixedRate = 1000*60*60*24)
public void sendEmaill() { public void sendEmaill() {
System.out.println("SendEmaillSchedule。。。。。。。。。。。。。。。"); System.out.println("SendEmaillSchedule。。。。。。。。。。。。。。。");
@ -62,7 +62,7 @@ public class SendEmaillSchedule {
+"<br/><img src='https://www.zinglizingli.xyz/me/assets/images/work001-01.jpg'>"; +"<br/><img src='https://www.zinglizingli.xyz/me/assets/images/work001-01.jpg'>";
mailService.sendHtmlMail(email, subject, content); mailService.sendHtmlMail(email, subject, content);
try { try {
Thread.sleep(new Random().nextInt(1000*60)+1000*60); Thread.sleep(new Random().nextInt(1000*60*10)+1000*60);
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.error(e.getMessage(),e); log.error(e.getMessage(),e);
} }

View File

@ -44,7 +44,7 @@ public class SendUrlSchedule {
private Logger log = LoggerFactory.getLogger(SendUrlSchedule.class); private Logger log = LoggerFactory.getLogger(SendUrlSchedule.class);
@Scheduled(cron = "0 0 1 * * 5") @Scheduled(cron = "0 0 1 * * 1")
public void sendAllBookToBaidu() { public void sendAllBookToBaidu() {
System.out.println("sendAllBookToBaidu。。。。。。。。。。。。。。。"); System.out.println("sendAllBookToBaidu。。。。。。。。。。。。。。。");
@ -70,6 +70,11 @@ public class SendUrlSchedule {
System.out.println("推送数据:" + reqBody); System.out.println("推送数据:" + reqBody);
ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?site=www.zinglizingli.xyz&token=IuK7oVrPKe3U606x", request, String.class); ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?site=www.zinglizingli.xyz&token=IuK7oVrPKe3U606x", request, String.class);
System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody()); System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
Thread.sleep(1000 * 10);
System.out.println("推送数据:" + reqBody);
stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?appid=1643715155923937&token=fkEcTlId6Cf21Sz3&type=batch", request, String.class);
System.out.println("推送URL结果code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
reqBody = ""; reqBody = "";
Thread.sleep(1000 * 10); Thread.sleep(1000 * 10);
} }

View File

@ -446,13 +446,14 @@ public class SendWeiboSchedule {
private String sendOneSiteWeibo(RestTemplate template, String bookName, String indexName, String author, String desc, String wapName, String bookNum, String href) { private String sendOneSiteWeibo(RestTemplate template, String bookName, String indexName, String author, String desc, String wapName, String bookNum, String href) {
String baseUrl = "http://service.weibo.com/share/aj_share.php"; String baseUrl = "http://service.weibo.com/share/aj_share.php";
Map<String, String> param = new HashMap<>(); Map<String, String> param = new HashMap<>();
String content = bookName + "小说最新章节列表," + bookName + "小说免费在线阅读," + bookName + /*String content = bookName + "小说最新章节列表," + bookName + "小说免费在线阅读," + bookName +
"小说TXT下载,尽在" + wapName +href+ "\n"; "小说TXT下载,尽在" + wapName +href+ "\n";
if(indexName != null){ if(indexName != null){
content+=("最新章节:"+indexName+"\n"); content+=("最新章节:"+indexName+"\n");
} }
content = content + "作者:"+(author.replace("作者:","")) + "\n"; content = content + "作者:"+(author.replace("作者:","")) + "\n";
content += ("简介:"+desc.replace("简介:","")); content += ("简介:"+desc.replace("简介:",""));*/
String content = bookName+"最新章节,小说"+bookName+"("+author.replace("作者:","")+")手机阅读,小说"+bookName+"TXT下载 - "+href;
param.put("content", content ); param.put("content", content );
param.put("styleid", "1"); param.put("styleid", "1");
param.put("from", "share"); param.put("from", "share");

View File

@ -3,9 +3,15 @@ server:
spring: spring:
datasource: datasource:
url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8 # url: jdbc:mysql://148.70.59.92:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: books # username: xiongxiaoyang
password: books # password: Lzslov123!
url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: xiongxiaoyang
password: Lzslov123!
# url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8
# username: books
# password: books
cache: cache:
ehcache: ehcache:
config: classpath:ehcache.xml config: classpath:ehcache.xml
@ -13,15 +19,15 @@ spring:
mode: LEGACYHTML5 #去除thymeleaf的html严格校验thymeleaf.mode=LEGACYHTML5 mode: LEGACYHTML5 #去除thymeleaf的html严格校验thymeleaf.mode=LEGACYHTML5
cache: true # 是否开启模板缓存默认true,建议在开发时关闭缓存,不然没法看到实时页面 cache: true # 是否开启模板缓存默认true,建议在开发时关闭缓存,不然没法看到实时页面
freemarker: freemarker:
template-loader-path: classpath:/templates #设定thymeleaf文件路径 默认为src/main/resources/templatestemplate-loader-path=classpath:/templates template-loader-path: classpath:/templates #设定freemarker文件路径 默认为src/main/resources/templatestemplate-loader-path=classpath:/templates
charset: UTF-8 # 模板编码 charset: UTF-8 # 模板编码
#邮箱服务器 #邮箱服务器
mail: mail:
host: smtp.163.com host: smtp.163.com
#邮箱账户 #邮箱账户
username: username: 13560421324@163.com
#你的QQ邮箱第三方授权码 #邮箱第三方授权码
password: password: xiong13560421324
#编码类型 #编码类型
default-encoding: UTF-8 default-encoding: UTF-8
port: 465 port: 465
@ -63,4 +69,4 @@ baidu:
browser: browser:
cookie: SINAGLOBAL=5945695441587.724.1559298271897; __guid=109181959.2094437407894937900.1565875017257.2095; un=13560421324; _s_tentry=-; Apache=8157572449986.1455.1566918991846; ULV=1566918991855:7:6:1:8157572449986.1455.1566918991846:1566086532731; login_sid_t=0cc80b9f5ea5f473e83fce3054291c03; cross_origin_proto=SSL; un=13560421324; YF-Widget-G0=4aade6ec367f09ec0a5eec921227137f; WBtopGlobal_register_version=307744aa77dd5677; SSOLoginState=1566928337; wvr=6; UOR=,,www.zinglizingli.xyz; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WFRg9065OjUyD0aaGsKRxPW5JpX5KMhUgL.Fo-f1hB7SKMp1h52dJLoI0qLxK-L1KqL1-eLxKMLB.-L122LxKMLB.-L122LxK-LBo5L12qLxKnLB-qLBoBLxKMLB.BL1K2t; ALF=1599046395; SCF=AsBEGOtiUG1hPLyZCxI1FunZd9Hg9hWWkgyzcAZjG6AxOiKPAEM99ZxY8qofeWw3xoU_Wh3OqNzt4BSkCAyD_8o.; SUB=_2A25waj8tDeRhGeNL41YR9SnNwzyIHXVTHhflrDV8PUNbmtANLXXAkW9NSM603mvU3tqplLCrqvedw1Q29U_TkxRA; SUHB=0xnyhR4nBtqt14; monitor_count=2; webim_unReadCount=%7B%22time%22%3A1567510495487%2C%22dm_pub_total%22%3A2%2C%22chat_group_client%22%3A0%2C%22allcountNum%22%3A36%2C%22msgbox%22%3A0%7D cookie: SINAGLOBAL=5945695441587.724.1559298271897; __guid=109181959.2094437407894937900.1565875017257.2095; un=13560421324; _s_tentry=login.sina.com.cn; Apache=967339021599.2916.1567743040489; ULV=1567743040504:8:1:1:967339021599.2916.1567743040489:1566918991855; login_sid_t=d172b083637b1186ebcd624a1259a05f; cross_origin_proto=SSL; appkey=; SSOLoginState=1567744755; YF-Widget-G0=4a4609df0e4ef6187a7b4717d4e6cf12; wvr=6; WBtopGlobal_register_version=307744aa77dd5677; un=13560421324; SCF=AsBEGOtiUG1hPLyZCxI1FunZd9Hg9hWWkgyzcAZjG6AxlhR9sKuWXBhvg1TG9iDWygqPlKun5aazN3Jc6Rky8lQ.; SUB=_2A25wfnGoDeRhGeNL41YR9SnNwzyIHXVTCuRgrDV8PUJbmtANLRWgkW9NSM603g9LJN13ACge6_UUjKxvhLP4TXZi; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WFRg9065OjUyD0aaGsKRxPW5JpX5K-hUgL.Fo-f1hB7SKMp1h52dJLoI0qLxK-L1KqL1-eLxKMLB.-L122LxKMLB.-L122LxK-LBo5L12qLxKnLB-qLBoBLxKMLB.BL1K2t; SUHB=0XDVz5Bh1mkWFA; ALF=1599812938; UOR=,,sf.zinglizingli.xyz; monitor_count=13; webim_unReadCount=%7B%22time%22%3A1568285775036%2C%22dm_pub_total%22%3A1%2C%22chat_group_client%22%3A0%2C%22allcountNum%22%3A29%2C%22msgbox%22%3A0%7D

View File

@ -354,7 +354,8 @@
<select id="queryNewstBook" resultMap="BaseResultMap"> <select id="queryNewstBook" resultMap="BaseResultMap">
select id,book_name,book_desc,author from book select id,book_name,book_desc,author from book
<foreach collection="collection" item="item" open="where id not in(" close=")" separator=","> <foreach collection="collection" item="item"
open="where id not in(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>

View File

@ -206,6 +206,10 @@
<a th:href="'/book/'+${book.id}+'/index.html'">查看完整目录</a> <a th:href="'/book/'+${book.id}+'/index.html'">查看完整目录</a>
</div> </div>
<!--
<div style="position: fixed;top:0px;left:0px;z-index:-100;opacity: 0" th:utext="${attacDivForSearch}"></div>
-->
<div th:replace="common/footer :: footer"> <div th:replace="common/footer :: footer">
</div> </div>

View File

@ -120,7 +120,7 @@
</a> </a>
<div style="padding: 20px" class="layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8"> <div style="padding: 20px" class="layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8">
<a th:href="'/book/'+ ${book.id} + '.html'"> <a th:href="'/book/'+ ${book.id} + '.html'">
<div class="line-limit-length" style=";color: #4c6978;font-weight: bold;font-size: 16px" <div class="line-limit-length" style=";color: #4c6978;font-weight: bold;font-size: 15px"
th:text="${book.bookName}"></div> th:text="${book.bookName}"></div>
</a> </a>
<div style=";color: #4c6978;float: right;"><i style="color: red" th:text="${book.score} + '分'"></i></div> <div style=";color: #4c6978;float: right;"><i style="color: red" th:text="${book.score} + '分'"></i></div>

View File

@ -159,7 +159,7 @@
</a> </a>
<div style="padding: 20px" class="layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8"> <div style="padding: 20px" class="layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8">
<a th:href="'/book/'+ ${book.id} + '.html'"> <a th:href="'/book/'+ ${book.id} + '.html'">
<div class="line-limit-length" style=";color: #4c6978;font-weight: bold;font-size: 20px" <div class="line-limit-length" style=";color: #4c6978;font-weight: bold;font-size: 15px"
th:text="${book.bookName}"></div> th:text="${book.bookName}"></div>
</a> </a>
<div style=";color: #4c6978;float: right;"><i style="color: red" th:text="${book.score} + '分'"></i></div> <div style=";color: #4c6978;float: right;"><i style="color: red" th:text="${book.score} + '分'"></i></div>