From b73dbb727ebf3f0b464b754209ede1647c1c2a1c Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 11 Mar 2020 08:56:21 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=9B=B4=E6=96=B0=E7=99=BE?= =?UTF-8?q?=E5=BA=A6SEO=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/vertical/util/BaiDuUtils.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java index 5e83cd0..83e015f 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) { @@ -77,7 +100,7 @@ public class BaiDuUtils { },executor); } - public static void main(String agrs[]){ - sendSEOData("https://rymcu.com/article/31"); + public static void main(){ + sendUpdateSEOData("https://rymcu.com"); } }