Geolocation 利用IP进行地理定位
我一直在尝试使用我的电脑Geolocation 利用IP进行地理定位,geolocation,ip,freegeoip,Geolocation,Ip,Freegeoip,我一直在尝试使用我的电脑ip找到一个工具来定位我的位置 我尝试过一些网络工具,如http://geoiplookup.net/和https://geoiptool.com/和一些开发工具,如freegoip.net,我对它们更感兴趣 事实是:地理定位在所有这些方面都相去甚远,至少在我所在的地方(南美、巴西),都指向同一个错误的位置 为什么会这样 我试过这段代码: send_url = 'http://freegeoip.net/json' r = requests.get(sen
ip
找到一个工具来定位我的位置
我尝试过一些网络工具,如http://geoiplookup.net/
和https://geoiptool.com/
和一些开发工具,如freegoip.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) 除了
谷歌地图
,是否还有其他工具可以找到我的精确纬度、液化天然气
?IP地址与其他地理定位方法(如GPS或WiFi MAC地址)相比,相对较不准确。原因是ISP频繁地重新分配IP地址
参考:
回到你的问题上来
1) API应该自动检测您的IP地址并返回估计的位置
2) 如果不启用GPS,您将无法找到精确的纬度和经度
检索位置、国家、城市、lat、lon、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>
geoipdb-jQuery示例
国家:
声明:
城市:
纬度:
经度:
知识产权:
$.ajax({
url:“https://geoip-db.com/jsonp",
jsonpCallback:“回调”,
数据类型:“jsonp”,
成功:功能(位置){
$('#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);
}
});