public String getBaiduNum(){
int pagesize =CHECKPAGE;
int count=0;
siteUrl = getCurrentWebsite().getDomain();
if(!siteUrl.endsWith("/")){
siteUrl+="/" ;
}
StringBuffer sb = new StringBuffer();
for(int i=0;i<pagesize;i++){
try {
Document doc = Jsoup.parse(new URL("
http://www.baidu.com/s?wd="+keyword+"&pn="+i*10+"&f=3&usm=1"), 10*1000);
Elements els = doc .select("table[class=result]");
for(Element e:els){
int index = e.html().toString().lastIndexOf(siteUrl);
if(index!=-1){
count++;
sb.append(e.attr("id").trim());
sb.append(",");
if(count==LIMITEDNUM) break;
}
}
if(count==LIMITEDNUM) break;
} catch (Exception e) {
LOG.error("檢測異常", e);
continue;
}
}
String paixu=sb.toString();;
if(paixu.endsWith(",")){
paixu=paixu.substring(0, paixu.length()-1);
}
if(StringUtils.isEmpty(paixu)){
paixu=CHECKPAGE+"頁之外";
}
return paixu;
}