获取手机号归属地

由于短信项目的需要,需要知道目前所有手机号的归属地,于是写了一个小程序,通过在线查询,获取手机号的归属地,暂不考虑虚拟运营商和换网手机号。
代码如下:
    @Test
    public void tt(){
        int v_i=20;
        for (;v_i<99;v_i++){
            get(Convert.toString(v_i));
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }finally {

            }
        }
    }

    public void get(String v_phone) {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        String v_url="http://v.showji.com/Locating/showji.com20150108.aspx?m=1"+ 
                v_phone+ "06331234&output=json&callback=querycallback&timestamp="+
                Convert.toString(System.currentTimeMillis());
        try {
            HttpGet httpget = new HttpGet(v_url);
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    String v_path=EntityUtils.toString(entity);
                    v_path=v_path.replaceAll("querycallback|;|\\)|\\(","");
                    if(v_path.length()<200) {
                        JSONObject json = JSON.parseObject(v_path);
                        if(!json.getString("Corp").equals("")) {
                            System.out.println(v_phone+" : "+json.getString("Mobile") + 
                                    " : " + json.getString("Corp"));
                        }
                    }
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

运行结果如下:

30 : 13006331234 : 中国联通
31 : 13106331234 : 中国联通
32 : 13206331234 : 中国联通
33 : 13306331234 : 中国电信
34 : 13406331234 : 中国移动
35 : 13506331234 : 中国移动
36 : 13606331234 : 中国移动
37 : 13706331234 : 中国移动
38 : 13806331234 : 中国移动
39 : 13906331234 : 中国移动
45 : 14506331234 : 中国联通
47 : 14706331234 : 中国移动
49 : 14906331234 : 中国电信
50 : 15006331234 : 中国移动
51 : 15106331234 : 中国移动
52 : 15206331234 : 中国移动
53 : 15306331234 : 中国电信
55 : 15506331234 : 中国联通
56 : 15606331234 : 中国联通
57 : 15706331234 : 中国移动
58 : 15806331234 : 中国移动
59 : 15906331234 : 中国移动
70 : 17006331234 : 中国电信
76 : 17606331234 : 中国联通
77 : 17706331234 : 中国电信
78 : 17806331234 : 中国移动
80 : 18006331234 : 中国电信
81 : 18106331234 : 中国电信
82 : 18206331234 : 中国移动
83 : 18306331234 : 中国移动
84 : 18406331234 : 中国移动
85 : 18506331234 : 中国联通
86 : 18606331234 : 中国联通
87 : 18706331234 : 中国移动
88 : 18806331234 : 中国移动
89 : 18906331234 : 中国电信
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值