360免费查询手机号归属API地接口

接口地址: https://cx.shouji.360.cn/phonearea.php?number=手机号


import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args0) throws IOException {

        FileWriter fileWriter = new FileWriter("d://test1.txt");

        String httpUrl = "https://cx.shouji.360.cn/phonearea.php";

        String httpArg = "";

        for (int i = 7000; i < 8000; i++) {

            if (i >= 1000) {

                httpArg = "number=188" + String.valueOf(i) + "4257";
                System.out.println(httpArg);

            } else if (i >= 100) {

                httpArg = "number=1880" + String.valueOf(i) + "4257";


            } else if (i >= 10) {

                httpArg = "number=18800" + String.valueOf(i) + "4257";


            } else {

                httpArg = "number=188000" + String.valueOf(i) + "4257";



            }

            String jsonResult = request(httpUrl, httpArg);

            String res = unicodeDecode(jsonResult);

            if (res.contains("长沙")) {
                System.out.println("号码:" + httpArg + "\t");
                fileWriter.write(httpArg + "\n\t");
                System.out.println("结果:" + res);
            }

        }

        fileWriter.flush();

        fileWriter.close();

    }

    /**

     * @param

     *            :请求接口

     * @param httpArg

     *            :参数

     * @return 返回结果

     */

    public static String request(String httpUrl, String httpArg) {

        BufferedReader reader = null;

        String result = null;

        StringBuffer sbf = new StringBuffer();

        httpUrl = httpUrl + "?" + httpArg;

        try {

            URL url = new URL(httpUrl);

            HttpURLConnection connection = (HttpURLConnection) url

                    .openConnection();

            connection.setRequestMethod("GET");

// 填入apikey到HTTP header

            //connection.setRequestProperty("apikey", "0574246ccaa94772abaf4f8229414249");

            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");

            }

            reader.close();

            result = sbf.toString();

        } catch (Exception e) {

            e.printStackTrace();

        }

        return result;

    }

    /**
     * @Title: unicodeDecode
     * @Description: unicode解码
     * @param string
     * @return
     */
    public static String unicodeDecode(String string) {
        Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
        Matcher matcher = pattern.matcher(string);
        char ch;
        while (matcher.find()) {
            ch = (char) Integer.parseInt(matcher.group(2), 16);
            string = string.replace(matcher.group(1), ch + "");
        }
        return string;
    }
}


posted @   ament  阅读(1639)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示