0

我一直在尝试寻找一种工具来使用我的电脑定位我的位置ip

我尝试了一些 Web 工具,例如http://geoiplookup.net/和 ,https://geoiptool.com/以及一些开发人员工具,例如freegeoip.net,我对这些工具更感兴趣。

事实是:地理位置在所有这些地方都存在偏差,至少在我所在的地方(南美,巴西),都指向同一个错误的位置

为什么会这样?

我试过这段代码:

    send_url = 'http://freegeoip.net/json'
    r = requests.get(send_url)
    j = json.loads(r.text)
    lat = j['latitude']
    lon = j['longitude']

    return (lat, lon)

但由于它使用了错误,它返回了一些离我很远的ip奇怪。lat/lgn

1)我可以在上面的代码中将我的精确值ip作为参数传递吗?

2)有没有其他工具可以找出我的精确度lat, lng,除了googlemaps

4

2 回答 2

1

与 GPS 或 WiFi MAC 地址等其他地理定位方法相比,IP 地址地理定位的准确度相对较低。原因是ISP频繁重新分配IP地址。

参考:http ://www.geolocation.com

回到你的问题。

1) API 应该自动检测您的 IP 地址并返回您估计的位置

2) 如果不启用 GPS,您将无法找到精确的经度和纬度

于 2017-03-15T05:17:56.730 回答
0

试试http://geoip-db.com的服务

一个用于检索位置、国家、城市、纬度、经度、ip 和状态的小 jQuery 示例:

<!DOCTYPE html>
<html>
<head>
    <title>GEOIP DB - jQuery example</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js">
</script>
</head>
<body>
    <div>Country: <span id="country"></span>
    <div>State: <span id="state"></span>
    <div>City: <span id="city"></span>
    <div>Latitude: <span id="latitude"></span>
    <div>Longitude: <span id="longitude"></span>
    <div>IP: <span id="IPv4"></span>
    <script>
    $.ajax({
        url: "https://geoip-db.com/jsonp",
        jsonpCallback: "callback",
        dataType: "jsonp",
        success: function( location ) {
            $('#country').html(location.country_name);
            $('#state').html(location.state);
            $('#city').html(location.city);
            $('#latitude').html(location.latitude);
            $('#longitude').html(location.longitude);
            $('#ip').html(location.IPv4);  
        }
    });     
    </script>
</body>
</html>
于 2017-06-02T12:16:19.717 回答