#!/usr/bin/env python # -*- coding: utf-8 -*- import signal import urllib import json import sys,os,re import socket url = "http://ip.taobao.com/service/getIpInfo.php?ip=" def ip_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"]["city"] ip_address = ‘114.114.114.114‘ city_address = ip_location(ip_address) print ip_address + ":" + city_address
时间: 2024-09-29 08:10:06