根据十进制或者十六进制MAC范围抓取全部运营商

来源:互联网 发布:好牧人12网络牧养中心 编辑:程序博客网 时间:2024/06/10 23:44

直接java码砖

public static void main(String[] args) {        // String mac="fc64ba9d9be7";        // String hexString = "fc64ba";        // System.out.println(hexString2binaryString(hexString));        //   (十六进制范围)000000 FFFFFF  (十进制范围)0-16777215        for(int i =0;i<=16777215;i++){            // 生成设备mac前六位            String aa=  padLeft(Integer.toHexString(i),6);            // 调用官方api抓取运营商输出结果  http://www.imfirewall.com/ip-mac-lookup/             request("http://www.imfirewall.com/ip-mac-lookup/get_mac_info.php",aa);        }    }    public static String padLeft(String s, int length)    {        byte[] bs = new byte[length];        byte[] ss = s.getBytes();        Arrays.fill(bs, (byte) (48 & 0xff));        System.arraycopy(ss, 0, bs,length - ss.length, ss.length);        return new String(bs);    }    public static String request(String httpUrl, String httpArg) {        Integer n=1;        BufferedReader reader = null;        String result = null;        StringBuffer sbf = new StringBuffer();        httpUrl = httpUrl + "?mac=" +httpArg+"&_="+System.currentTimeMillis() ;        try {            URL url = new URL(httpUrl);            HttpURLConnection connection = (HttpURLConnection) url                    .openConnection();            connection.setRequestMethod("GET");            connection.setRequestProperty("apikey",  "71e4b699*********cf44ebb02cd2");            //connection.setRequestProperty("apikey",  "71e4b699*********cf44ebb02cd2");            connection.connect();            InputStream is = connection.getInputStream();            reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));            String strRead = null;            while ((strRead = reader.readLine()) != null) {                sbf.append(strRead);                sbf.append("\r\n");            }            System.out.println(sbf);            reader.close();            result = sbf.toString();        } catch (Exception e) {            e.printStackTrace();        }        return result;    }
原创粉丝点击