mirror of
https://github.com/201206030/novel.git
synced 2025-06-24 08:06:39 +00:00
v2.0.3发布
This commit is contained in:
@ -102,8 +102,8 @@ public class SearchFilter implements Filter {
|
||||
|
||||
try {
|
||||
|
||||
OutputStream out = resp.getOutputStream();
|
||||
if(requestURI.contains("/localPic/")){
|
||||
OutputStream out = resp.getOutputStream();
|
||||
InputStream input = new FileInputStream(new File(picSavePath+requestURI));
|
||||
byte[] b = new byte[4096];
|
||||
for (int n; (n = input.read(b)) != -1;) {
|
||||
@ -193,6 +193,7 @@ public class SearchFilter implements Filter {
|
||||
String realUrl = "https://images.dmzj.com/" + requestURI.substring(15);
|
||||
ResponseEntity<Resource> resEntity = restTemplate.exchange(realUrl, HttpMethod.GET, requestEntity, Resource.class);
|
||||
InputStream input = resEntity.getBody().getInputStream();
|
||||
OutputStream out = resp.getOutputStream();
|
||||
byte[] b = new byte[4096];
|
||||
for (int n; (n = input.read(b)) != -1;) {
|
||||
out.write(b, 0, n);
|
||||
|
@ -38,7 +38,9 @@ public class CrawlBooksSchedule {
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
RestTemplate restTemplate = RestTemplateUtil.getInstance("utf-8");
|
||||
RestTemplate utf8RestTemplate = RestTemplateUtil.getInstance("utf-8");
|
||||
|
||||
RestTemplate isoRestTemplate = RestTemplateUtil.getInstance("iso-8859-1");
|
||||
|
||||
@Value("${books.lowestScore}")
|
||||
private Float lowestScore;
|
||||
@ -166,10 +168,9 @@ public class CrawlBooksSchedule {
|
||||
String picSrc = picMather.group(1);
|
||||
|
||||
if(picSaveType == 2 && StringUtils.isNotBlank(picSrc)){
|
||||
restTemplate = RestTemplateUtil.getInstance("iso-8859-1");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
||||
ResponseEntity<Resource> resEntity = restTemplate.exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
||||
ResponseEntity<Resource> resEntity = isoRestTemplate.exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
||||
InputStream input = resEntity.getBody().getInputStream();
|
||||
picSrc = "/localPic/" + updateTimeStr.substring(0,4)+"/"+updateTimeStr.substring(5,7)+"/"+updateTimeStr.substring(8,10)
|
||||
+ UUIDUtils.getUUID32()
|
||||
@ -528,11 +529,10 @@ public class CrawlBooksSchedule {
|
||||
String picSrc = picMather.group(1);
|
||||
|
||||
if(picSaveType == 2 && StringUtils.isNotBlank(picSrc)){
|
||||
restTemplate = RestTemplateUtil.getInstance("iso-8859-1");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Referer","https://www.biqudao.com");
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
||||
ResponseEntity<Resource> resEntity = restTemplate.exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
||||
ResponseEntity<Resource> resEntity = isoRestTemplate.exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
||||
InputStream input = resEntity.getBody().getInputStream();
|
||||
picSrc = "/localPic/" + updateTimeStr.substring(0,2)+"/"+updateTimeStr.substring(3,5)+"/"+updateTimeStr.substring(6,8)
|
||||
+ UUIDUtils.getUUID32()
|
||||
@ -670,7 +670,7 @@ public class CrawlBooksSchedule {
|
||||
|
||||
}
|
||||
|
||||
private String getByHttpClient(String catBookListUrl) {
|
||||
private String getByHttpClient(String url) {
|
||||
try {
|
||||
/* HttpClient httpClient = new DefaultHttpClient();
|
||||
HttpGet getReq = new HttpGet(catBookListUrl);
|
||||
@ -683,7 +683,7 @@ public class CrawlBooksSchedule {
|
||||
return null;
|
||||
}*/
|
||||
//经测试restTemplate比httpClient效率高出很多倍,所有选择restTemplate
|
||||
ResponseEntity<String> forEntity = restTemplate.getForEntity(catBookListUrl, String.class);
|
||||
ResponseEntity<String> forEntity = utf8RestTemplate.getForEntity(url, String.class);
|
||||
if (forEntity.getStatusCode() == HttpStatus.OK) {
|
||||
return forEntity.getBody();
|
||||
} else {
|
||||
|
@ -4,8 +4,8 @@ server:
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: test123456
|
||||
username: books
|
||||
password: books
|
||||
# url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: test123456
|
||||
@ -77,7 +77,7 @@ crawl:
|
||||
pic:
|
||||
save:
|
||||
type: 1 #图片保存方式, 1不保存,使用网络图片 ,2本地保存
|
||||
path: d:/pic #图片保存路径
|
||||
path: /var/pic #图片保存路径
|
||||
|
||||
|
||||
search:
|
||||
|
Reference in New Issue
Block a user