python通过ip获取地址
# -*- coding: utf-8 -*-
url = "http://ip.taobao.com/service/getIpInfo.php?ip="
#查找IP地址
defip_location(ip):
data = urllib.urlopen(url + ip).read()
datadict=json.loads(data)
for oneinfo in datadict:
if "code" == oneinfo:
if datadict[oneinfo] == 0:
return datadict["data"]["country"] + datadict["data"]["region"] + datadict["data"]["city"] + datadict["data"]["isp"]