自学内容网 自学内容网

全球IP归属地查询-IP地址查询-IP城市查询-IP地址归属地-IP地址解析-IP位置查询-IP地址查询API接口-IP查询城市-IP解析城市

IP地址查询接口是指能够返回IP地址相关信息的网络接口,其返回的信息通常包括IP地址的归属地(如国家、省份、城市等)、运营商信息以及其他技术细节。以下是一些常见的IP地址查询接口及其特点:

一、国内IP地址查询接口

  1. 百度IP地址查询接口

  2. 具体信息

Java代码实现

//https://market.aliyun.com/apimarket/detail/cmapi00066996?spm=5176.730005.result.2.5ef9414ayVtSoP#sku=yuncode6099600002
public static void main(String[] args) {
    String host = "https://kzipglobal.market.alicloudapi.com";
    String path = "/api/ip/query";
    String method = "POST";
    String appcode = "你自己的AppCode";
    Map<String, String> headers = new HashMap<String, String>();
    //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
    headers.put("Authorization", "APPCODE " + appcode);
    //根据API的要求,定义相对应的Content-Type
    headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    Map<String, String> querys = new HashMap<String, String>();
    Map<String, String> bodys = new HashMap<String, String>();
    bodys.put("ip", "39.170.93.199");


    try {
    /**
    * 重要提示如下:
    * HttpUtils请从
    * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
    * 下载
    *
    * 相应的依赖请参照
    * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
    */
    HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
    System.out.println(response.toString());
    //获取response的body
    //System.out.println(EntityUtils.toString(response.getEntity()));
    } catch (Exception e) {
    e.printStackTrace();
    }
}

ip解析城市结果

{
    "msg": "成功",
    "success": true,
    "code": 200,
    "data": {
        "orderNo": "202408040848319168904",
        "nation": "中国",
        "province": "浙江省", //省份
        "city": "杭州市", //城市
        "ip": "39.170.93.199",  //本机ip
        "isp": "移动" //运营商
    }
}


原文地址:https://blog.csdn.net/hm_cth_lfq/article/details/142744583

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!