public class CheckBaiduIncludeUtil {
public static void main(String[] args) {
String html = checkBaiduInclude("www.wuliaokankan.cn/long_detail/6948.html");
if( !"".equals(html) ){
Document doc = Jsoup.parse(html);
Element element = doc.getElementsByClass("content_none").first();
if( null == element ){
System.out.println("百度已经收录该网址");
}else{
System.out.println("百度没有收录该网址");
}
}
}
/**
* java检测百度是否收录网站url
* @param siteurl
* @return
*/
public static String checkBaiduInclude(String siteurl) {
String url = "https://www.baidu.com/s?wd="+siteurl;
try {
Response resp = Jsoup.connect(url)
.timeout(60000)
.method(Connection.Method.GET)
.maxBodySize(0)
.followRedirects(false)
.execute();
return new String(resp.bodyAsBytes());
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
}
java检测百度是否收录网站url
最新推荐文章于 2022-11-09 11:50:39 发布