mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
修复链接推送失败报错的提示
This commit is contained in:
parent
a9ca517edc
commit
cf347cdf98
@ -507,69 +507,71 @@ public class BookService {
|
|||||||
|
|
||||||
|
|
||||||
private void sendNewstBook(Long bookId) {
|
private void sendNewstBook(Long bookId) {
|
||||||
if (bookId >= 0) {
|
try {
|
||||||
|
if (bookId >= 0) {
|
||||||
|
|
||||||
//List<String> idList = queryEndBookIdList();
|
//List<String> idList = queryEndBookIdList();
|
||||||
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("User-Agent","curl/7.12.1");
|
||||||
headers.add("Host", "data.zz.baidu.com");
|
headers.add("Host", "data.zz.baidu.com");
|
||||||
|
|
||||||
|
String reqBody = "";
|
||||||
|
reqBody += ("https://www.zinglizingli.xyz/book/" + bookId + ".html" + "\n");
|
||||||
|
//reqBody += ("http://www.zinglizingli.xyz/book/" + bookId + ".html" + "\n");
|
||||||
|
headers.setContentLength(reqBody.length());
|
||||||
|
HttpEntity<String> request = new HttpEntity<>(reqBody, headers);
|
||||||
|
System.out.println("推送数据:" + reqBody);
|
||||||
|
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());
|
||||||
|
|
||||||
String reqBody = "";
|
|
||||||
reqBody += ("https://www.zinglizingli.xyz/book/" + bookId + ".html" + "\n");
|
|
||||||
//reqBody += ("http://www.zinglizingli.xyz/book/" + bookId + ".html" + "\n");
|
|
||||||
headers.setContentLength(reqBody.length());
|
|
||||||
HttpEntity<String> request = new HttpEntity<>(reqBody, headers);
|
|
||||||
System.out.println("推送数据:" + reqBody);
|
|
||||||
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());
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000 * 3);
|
Thread.sleep(1000 * 3);
|
||||||
|
|
||||||
//reqBody += ("http://www.zinglizingli.xyz/book/" + bookId + ".html" + "\n");
|
//reqBody += ("http://www.zinglizingli.xyz/book/" + bookId + ".html" + "\n");
|
||||||
System.out.println("推送数据:" + reqBody);
|
System.out.println("推送数据:" + reqBody);
|
||||||
stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?appid=1643715155923937&token=fkEcTlId6Cf21Sz3&type=batch", request, String.class);
|
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());
|
System.out.println("推送URL结果:code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.info(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void sendNewstIndex(BookIndex bookIndex) {
|
private void sendNewstIndex(BookIndex bookIndex) {
|
||||||
if (bookIndex != null) {
|
try {
|
||||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
if (bookIndex != null) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
||||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Host", "data.zz.baidu.com");
|
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||||
String reqBody = "";
|
headers.add("Host", "data.zz.baidu.com");
|
||||||
//目录只推送最新一条
|
String reqBody = "";
|
||||||
reqBody += ("https://www.zinglizingli.xyz/book/" +
|
//目录只推送最新一条
|
||||||
bookIndex.getBookId() + "/" +
|
reqBody += ("https://www.zinglizingli.xyz/book/" +
|
||||||
bookIndex.getIndexNum() + ".html" + "\n");
|
bookIndex.getBookId() + "/" +
|
||||||
headers.setContentLength(reqBody.length());
|
bookIndex.getIndexNum() + ".html" + "\n");
|
||||||
HttpEntity<String> request = new HttpEntity<>(reqBody, headers);
|
headers.setContentLength(reqBody.length());
|
||||||
System.out.println("推送数据:" + reqBody);
|
HttpEntity<String> request = new HttpEntity<>(reqBody, headers);
|
||||||
ResponseEntity<String> stringResponseEntity = restTemplate.
|
System.out.println("推送数据:" + reqBody);
|
||||||
postForEntity("http://data.zz.baidu.com/urls?" +
|
ResponseEntity<String> stringResponseEntity = restTemplate.
|
||||||
"site=www.zinglizingli.xyz&token=IuK7oVrPKe3U606x"
|
postForEntity("http://data.zz.baidu.com/urls?" +
|
||||||
, request, String.class);
|
"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);
|
Thread.sleep(1000 * 3);
|
||||||
//reqBody += ("http://www.zinglizingli.xyz/book/" + index.getBookId() + "/" + index.getIndexNum() + ".html" + "\n");
|
//reqBody += ("http://www.zinglizingli.xyz/book/" + index.getBookId() + "/" + index.getIndexNum() + ".html" + "\n");
|
||||||
System.out.println("推送数据:" + reqBody);
|
System.out.println("推送数据:" + reqBody);
|
||||||
stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?appid=1643715155923937&token=fkEcTlId6Cf21Sz3&type=batch", request, String.class);
|
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());
|
System.out.println("推送URL结果:code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.info(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
<!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
|
<!-- 指定项目中某个包,当有日志操作行为时的日志记录级别 -->
|
||||||
<!-- com.maijinjie.springboot 为根包,也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
|
<!-- com.maijinjie.springboot 为根包,也就是只要是发生在这个根包下面的所有日志操作行为的权限都是DEBUG -->
|
||||||
<!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
|
<!-- 级别依次为【从高到低】:FATAL > ERROR > WARN > INFO > DEBUG > TRACE -->
|
||||||
<logger name="*" level="ERROR">
|
<logger name="*" level="DEBUG">
|
||||||
<appender-ref ref="debug" />
|
<appender-ref ref="debug" />
|
||||||
</logger>
|
</logger>
|
||||||
</configuration>
|
</configuration>
|
Loading…
x
Reference in New Issue
Block a user