用jq获取访问用户的ip地址所在城市

知识点,获取访问用户的各种资料


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

//通过调用新浪IP地址库接口查询用户当前所在国家、省份、城市、运营商信息
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){

console.log(remote_ip_info);

//输出对象
{
city:"深圳",
country:"中国",
desc:"",
district:"",
end:-1isp:"",
province:"广东",
ret:1,
start:-1,
type:""
}

});




var url = 'http://chaxun.1616.net/s.php?type=ip&output=json&callback=?&_='+Math.random();
$.getJSON(url, function(data){

console.log(data)

//输出对象
{
Browser:"Google Chrome 56.0.2924.87",
Ip:"183.39.000.000",
Isp:"广东省深圳市 电信",
OS:"Windows NT",
QueryResult:1
}

});