From 9329ec074d611dc65b4278528f25f4b76573f00a Mon Sep 17 00:00:00 2001 From: ronger Date: Sun, 19 Jan 2020 22:47:34 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=BC=95=E5=85=A5=E7=99=BE?= =?UTF-8?q?=E5=BA=A6=E7=AB=99=E7=82=B9=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/vertical/util/BaiDuUtils.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java index f207734..77ff880 100644 --- a/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java +++ b/src/main/java/com/rymcu/vertical/util/BaiDuUtils.java @@ -3,7 +3,6 @@ package com.rymcu.vertical.util; import jodd.http.HttpRequest; import jodd.http.HttpResponse; import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Value; import java.util.concurrent.*; @@ -12,13 +11,11 @@ import java.util.concurrent.*; */ public class BaiDuUtils { - @Value("${baidu.data.token}") - private static String token; - @Value("${baidu.data.site}") - private static String site; + private static String token = "9cdKR6bVCJzxDEJS"; + private static String site = "https://rymcu.com"; - public static void sendSEOData(String articlePermalink) { - if (StringUtils.isBlank(articlePermalink) || StringUtils.isBlank(token)) { + public static void sendSEOData(String permalink) { + if (StringUtils.isBlank(permalink) || StringUtils.isBlank(token)) { return; } ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); @@ -28,12 +25,17 @@ public class BaiDuUtils { header("User-Agent", "curl/7.12.1"). header("Host", "data.zz.baidu.com"). header("Content-Type", "text/plain"). - header("Connection", "close").body(articlePermalink.getBytes(), "text/plain").timeout(30000).send(); + 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); } + + public static void main(String agrs[]){ + sendSEOData("https://rymcu.com/article/31"); + } }