使用第三方的接口基本都收費,百度和360搜索可以直接輸入號碼查詢標識狀態,這里我使用Jsoup爬蟲快速實現號碼標識查詢功能。
1 public static JSONObject so(String mobile){ 2 JSONObject jsonObject=new JSONObject(); 3 jsonObject.put("count",0);//多少人標識 4 try { 5 Connection con = Jsoup.connect("https://www.so.com/s?q="+mobile); 6 con.header("Host", "https://www.so.com"); 7 con.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"); 8 con.header("Content-Type", "application/x-www-form-urlencoded"); 9 con.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"); 10 Document doc=con.get(); 11 String count=doc.select(".mohe-tips b").text(); 12 if(StringUtils.isNotBlank(count)){ 13 jsonObject.put("count",count);//多少人標識 14 jsonObject.put("address",doc.select(".mohe-mobileInfoContent .mh-detail span").last().text());//地址 15 jsonObject.put("type",doc.select(".mohe-tips .mohe-ph-mark").text());//標識類別 16 jsonObject.put("source",doc.select(".mohe-tips .mohe-sjws").text());//來源 17 jsonObject.put("date",EasyDate.getCurrentDateString()); 18 } 19 } catch (Exception e) { 20 e.printStackTrace(); 21 return jsonObject; 22 } 23 return jsonObject; 24 } 25 public static JSONObject baidu(String mobile){ 26 JSONObject jsonObject=new JSONObject(); 27 jsonObject.put("count",0);//多少人標識 28 try {
Connection con = Jsoup.connect("https://www.baidu.com/s?wd="+mobile); 31 con.header("Host", "www.baidu.com"); 32 con.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"); 33 con.header("Content-Type", "application/x-www-form-urlencoded"); 34 con.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"); 35 Document doc=con.get();
String source=doc.select(".op_fraudphone_word a").text();
if(StringUtils.isNotBlank(source)){ 41 jsonObject.put("source",doc.select(".op_fraudphone_word a").text());//來源 42 String desc=doc.select(".op_fraudphone_word").text(); 43 if(StringUtils.isNotBlank(desc)){ 44 String count=desc.substring(desc.indexOf("被")+1,desc.indexOf("個")); 45 jsonObject.put("count",count);//多少人標識 46 } 47 jsonObject.put("address",doc.select(".op_fraudphone_addr").text());//地址 48 jsonObject.put("type",doc.select(".op_fraudphone_label").text());//標識類別 49 jsonObject.put("date",EasyDate.getCurrentDateString()); 50 } 51 } catch (Exception e) { 52 e.printStackTrace(); 53 return jsonObject; 54 }
return jsonObject; 57 } 58 public static void main(String[] args) throws IOException { 59 // String mobile="073184145266"; 60 String mobile="037110016"; 61 System.out.println(baidu(mobile)); 62 System.out.println(so(mobile)); 63 64 }