# -*- 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

 

posted on 2016-05-11 14:36  昨、夜星辰  阅读(1066)  评论(0)    收藏  举报