首页 > 其他 > 详细

获取指定IP地址对应的物理位置

时间:2016-05-11 15:16:24      阅读:200      评论:0      收藏:0      [点我收藏+]
# -*- coding: utf-8 -*-
import requests
 
def get_physical_location(ip):
    url = http://ip.taobao.com/service/getIpInfo.php?ip= + ip
    r = requests.get(url)
    if r.json()[code]:
        print 您输入的ip地址有误,请检查后再试。
    else:
        country = r.json()[data][country]
        region = r.json()[data][region]
        city = r.json()[data][city]
        return country + region + city

 

获取指定IP地址对应的物理位置

原文:http://www.cnblogs.com/yestreenstars/p/5481802.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!