From 2ce6c5f9e76ec9227895e8cced2ab56ed1eca853 Mon Sep 17 00:00:00 2001 From: ronger Date: Mon, 30 Mar 2020 17:51:49 +0800 Subject: [PATCH] =?UTF-8?q?:speech=5Fballoon:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/vertical/util/BaiDuUtils.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java index 4a803c7..ec6ce89 100644 --- a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java +++ b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java @@ -33,6 +33,29 @@ public class BaiDuUtils { } return 0; },executor); + return; + } + + public static void sendUpdateSEOData(String permalink) { + if (StringUtils.isBlank(permalink) || StringUtils.isBlank(token)) { + return; + } + ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); + CompletableFuture.supplyAsync(()-> { + try { + HttpResponse response = HttpRequest.post("http://data.zz.baidu.com/update?site=" + site + "&token=" + token). + header("User-Agent", "curl/7.12.1"). + header("Host", "data.zz.baidu.com"). + header("Content-Type", "text/plain"). + header("Connection", "close").body(permalink.getBytes(), "text/plain").timeout(30000).send(); + response.charset("UTF-8"); + System.out.println(response.bodyText()); + } catch (Exception e){ + e.printStackTrace(); + } + return 0; + },executor); + return; } public static void updateSEOData(String permalink) { @@ -78,6 +101,6 @@ public class BaiDuUtils { } public static void main(String[] args){ - sendSEOData("https://rymcu.com"); + sendUpdateSEOData("https://rymcu.com"); } }