电脑常识——利用IP定位

版权声明:double12754 https://blog.csdn.net/double12754/article/details/88409717

http://www.chaipip.com/
https://www.ipplus360.com/search/ip/
这两个网址可以精确定位IP所在街道。可能需要科学上网。
下方是转载来的一个python做的用来精确定位的小程序,没有试过,准备以后有时间仔细看看。

# -- coding:utf-8 --
# author:allen权
import sys
import urllib2
import json

def get_ip_information(ip):
url=‘http://api.map.baidu.com/highacciploc/v1?qcip=’+ip+’&qterm=pc&ak=‘你的密钥(AK)’&coord=bd09ll&extensions=3
poiss=’’
request = urllib2.Request(url)
page = urllib2.urlopen(request, timeout=10)
data_json = page.read()
data_dic = json.loads(data_json)
if(data_dic.has_key(“content”)):
content=data_dic[“content”]
address_component=content[“address_component”]
formatted_address=content[“formatted_address”]
print “该IP地址的具体位置为:”
print address_component[“country”]
print formatted_address
if (content.has_key(“pois”)):
print “该IP地址附近POI信息如下:”
pois = content[“pois”]
for index in range(len(pois)):
pois_name = pois[index][“name”]
pois_address = pois[index][“address”]
print pois_name, pois_address
else:
print ‘IP地址定位失败!!!’
if name == ‘main’:
get_ip_information(‘183.55.116.95’)
程序部分转自:https://www.cnblogs.com/Shepherdzhao/p/7768597.html

猜你喜欢

转载自blog.csdn.net/double12754/article/details/88409717
今日推荐