✨ 引入百度站点工具
This commit is contained in:
parent
558c989254
commit
9329ec074d
@ -3,7 +3,6 @@ package com.rymcu.vertical.util;
|
|||||||
import jodd.http.HttpRequest;
|
import jodd.http.HttpRequest;
|
||||||
import jodd.http.HttpResponse;
|
import jodd.http.HttpResponse;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
@ -12,13 +11,11 @@ import java.util.concurrent.*;
|
|||||||
*/
|
*/
|
||||||
public class BaiDuUtils {
|
public class BaiDuUtils {
|
||||||
|
|
||||||
@Value("${baidu.data.token}")
|
private static String token = "9cdKR6bVCJzxDEJS";
|
||||||
private static String token;
|
private static String site = "https://rymcu.com";
|
||||||
@Value("${baidu.data.site}")
|
|
||||||
private static String site;
|
|
||||||
|
|
||||||
public static void sendSEOData(String articlePermalink) {
|
public static void sendSEOData(String permalink) {
|
||||||
if (StringUtils.isBlank(articlePermalink) || StringUtils.isBlank(token)) {
|
if (StringUtils.isBlank(permalink) || StringUtils.isBlank(token)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
|
ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
|
||||||
@ -28,12 +25,17 @@ public class BaiDuUtils {
|
|||||||
header("User-Agent", "curl/7.12.1").
|
header("User-Agent", "curl/7.12.1").
|
||||||
header("Host", "data.zz.baidu.com").
|
header("Host", "data.zz.baidu.com").
|
||||||
header("Content-Type", "text/plain").
|
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");
|
response.charset("UTF-8");
|
||||||
|
System.out.println(response.bodyText());
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
},executor);
|
},executor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String agrs[]){
|
||||||
|
sendSEOData("https://rymcu.com/article/31");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user