利用搜狐IP地址查询接口获取客户端ip

in 笔记 with 0 comment

搜狐IP地址查询接口如下:

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

接口返回一个json数组,比如

var returnCitySN = {"cip": "1.81.184.1", "cid": "610700", "cname": "陕西省汉中市"};

使用方法实例代码:

<script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
<script language="JavaScript">
    var clientIP = returnCitySN["cip"];
    alert(clientIP);
</script>

示例:
https://fanfpy.top/ip.html
ip截图

Responses