2020-01-14 17:35:02 +08:00
|
|
|
package com.rymcu.vertical.util;
|
|
|
|
|
|
|
|
import jodd.http.HttpRequest;
|
|
|
|
import jodd.http.HttpResponse;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author ronger
|
|
|
|
*/
|
|
|
|
public class BaiDuUtils {
|
|
|
|
|
2020-01-19 22:47:34 +08:00
|
|
|
private static String token = "9cdKR6bVCJzxDEJS";
|
|
|
|
private static String site = "https://rymcu.com";
|
2020-01-14 17:35:02 +08:00
|
|
|
|
2020-01-19 22:47:34 +08:00
|
|
|
public static void sendSEOData(String permalink) {
|
|
|
|
if (StringUtils.isBlank(permalink) || StringUtils.isBlank(token)) {
|
2020-01-14 17:35:02 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
CompletableFuture.supplyAsync(()-> {
|
|
|
|
try {
|
|
|
|
HttpResponse response = HttpRequest.post("http://data.zz.baidu.com/urls?site=" + site + "&token=" + token).
|
|
|
|
header("User-Agent", "curl/7.12.1").
|
|
|
|
header("Host", "data.zz.baidu.com").
|
|
|
|
header("Content-Type", "text/plain").
|
2020-01-19 22:47:34 +08:00
|
|
|
header("Connection", "close").body(permalink.getBytes(), "text/plain").timeout(30000).send();
|
2020-01-14 17:35:02 +08:00
|
|
|
response.charset("UTF-8");
|
2020-01-19 22:47:34 +08:00
|
|
|
System.out.println(response.bodyText());
|
2020-01-14 17:35:02 +08:00
|
|
|
} catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
},executor);
|
2020-03-11 08:56:21 +08:00
|
|
|
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<Runnable>());
|
|
|
|
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;
|
2020-01-14 17:35:02 +08:00
|
|
|
}
|
2020-01-19 22:47:34 +08:00
|
|
|
|
2020-02-15 15:07:26 +08:00
|
|
|
public static void updateSEOData(String permalink) {
|
|
|
|
if (StringUtils.isBlank(permalink) || StringUtils.isBlank(token)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void deleteSEOData(String permalink) {
|
|
|
|
if (StringUtils.isBlank(permalink) || StringUtils.isBlank(token)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ExecutorService executor= new ThreadPoolExecutor(1,1,0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
CompletableFuture.supplyAsync(()-> {
|
|
|
|
try {
|
|
|
|
HttpResponse response = HttpRequest.post("http://data.zz.baidu.com/del?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);
|
|
|
|
}
|
|
|
|
|
2020-03-11 08:56:21 +08:00
|
|
|
public static void main(){
|
|
|
|
sendUpdateSEOData("https://rymcu.com");
|
2020-01-19 22:47:34 +08:00
|
|
|
}
|
2020-01-14 17:35:02 +08:00
|
|
|
}
|