Java 获取区域号段

jar 在下面自己下载
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package phone;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

/**
 *
 * @author Administrator
 */
public class JavaApp {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        //获取连接  
        HttpClient httpclient = new DefaultHttpClient();
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        //String ok="";
        //三大运营商每年都有新号段根据情况添加号段
        String[] haoduan = {"130", "131", "132", "133", "134", "135", "136", "137", "138", "153", "155", "156", "189", "139", "150", "151", "152", "157","185","186", "145", "180", "158", "159", "182", "183", "187", "188", "147"};
        for (String x : haoduan) {
            //System.out.println(x);
            for (int i = 0; i < 10000; i++) {
                int k = Integer.parseInt(x) * 10000;
                k = k + i;
                // System.out.println(k);
                HttpGet httpget = new HttpGet("http://haoma.imobile.com.cn/index.php?mob=" + k);
                //HttpGet httpget = new HttpGet("http://www.ip138.com:8080/search.asp?action=mobile&mobile="+k);
                String responseBody = httpclient.execute(httpget, responseHandler);
                //System.out.println(responseBody);
                //JSONObject json = JSON.parseObject(responseBody);

                if (responseBody.indexOf("上海") > 0) {  //修改你想获取地区号码
                    // ok=ok+"|"+k;
                    System.out.println(k + "【上海】-" + YunYingShang(x));//修改你想获取地区号码
                    //ps = (PreparedStatement) conn.prepareStatement("insert into allnumber(number,Callerloc,tmobile) values (?,?,?)");
                }
            }
        }
    }
    public static String YunYingShang(String s) {
        switch (s) {
            default:
           case "130":
                return "联通";
            case "131":
                return "联通";
            case "132":
                return "联通";
            case "155":
                return "联通";
            case "156":
                return "联通";
            case "186":
                return "联通";
            case "145":
                return "联通";
            case "185":
                return "联通";
            case "134":
                return "移动";
            case "135":
                return "移动";
            case "136":
                return "移动";
            case "137":
                return "移动";
            case "138":
                return "移动";         
            case "139":
                return "移动";
            case "150":
                return "移动";
            case "151":
                return "移动";
            case "152":
                return "移动";
            case "157":
                return "移动";
            case "158":
                return "移动";
            case "159":
                return "移动";
            case "182":
                return "移动";
            case "183":
                return "移动";
            case "187":
                return "移动";
            case "188":
                return "移动";
            case "147":
                return "移动";
            case "180":
                return "电信";
            case "181":
                return "电信";
            case "133":
                return "电信";
            case "153":
                return "电信";            
            case "189":
                return "电信";
        }
    }
}


祝你好运!!!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值