java手机号码中奖查询,Java实现查询手机号码被标记功能

使用第三方的接口基本都收费,百度和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 }

标签:Java,String,标记,jsonObject,doc,text,手机号码,put,con

来源: https://www.cnblogs.com/java-rocky/p/11760449.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值