外网IP获取API

  • ~1.86K 字

开发过程中可能会用到的IP获取

  1. 搜狐(默认GBK编码)

    http://pv.sohu.com/cityjson?ie=utf-8

    返回结果如下:

    1
    var returnCitySN = {"cip": "220.249.113.155", "cid": "420100", "cname": "湖北省武汉市"};
  2. 淘宝

    https://www.taobao.com/help/getip.php

    返回结果如下:

    1
    ipCallback({ip:"220.249.113.155"})
  3. Ip-api

    http://ip-api.com/json

    返回结果如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    {
    status: "success",
    country: "China",
    countryCode: "CN",
    region: "HB",
    regionName: "Hubei",
    city: "Wuhan",
    zip: "",
    lat: 30.589,
    lon: 114.2681,
    timezone: "Asia/Shanghai",
    isp: "CNC Group CHINA169 Hubei Province Network",
    org: "Wuhan University",
    as: "AS4837 CHINA UNICOM China169 Backbone",
    query: "220.249.113.155"
    }

    添加参数返回不一样的值

    http://ip-api.com/json/?lang=zh-CN

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    {
    status: "success",
    country: "中国",
    countryCode: "CN",
    region: "HB",
    regionName: "湖北省",
    city: "武汉",
    zip: "",
    lat: 30.589,
    lon: 114.2681,
    timezone: "Asia/Shanghai",
    isp: "CNC Group CHINA169 Hubei Province Network",
    org: "Wuhan University",
    as: "AS4837 CHINA UNICOM China169 Backbone",
    query: "220.249.113.155"
    }

    或者查询某个IP的信息

    http://ip-api.com/json/81.69.6.231?lang=zh-CN

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    {
    status: "success",
    country: "荷兰",
    countryCode: "NL",
    region: "NH",
    regionName: "North Holland",
    city: "Amsterdam",
    zip: "1015",
    lat: 52.3798,
    lon: 4.88814,
    timezone: "Europe/Amsterdam",
    isp: "EuroNet Internet",
    org: "Wanadoo Nederland BV",
    as: "AS45090 Shenzhen Tencent Computer Systems Company Limited",
    query: "81.69.6.231"
    }
赞助喵
非常感谢您的喜欢!
赞助喵
分享这一刻
让朋友们也来瞅瞅!