# Solution II: ip_url = ["http://www.trackip.net/", 'http://www.ip.cn/'] for i in range(len(ip_url)): urlstring = requests.get(ip_url[i]).content ip = re.findall(b'\d+\.\d+\.\d+\.\d+', urlstring)[0].decode() if ip == '' and i != len(ip_url) - 1: AlertObj.Warn("Fail to get your IP Address({} Try)".format(i + 1)) continue elif ip == '' and i == len(ip_url) - 1: AlertObj.Warn( "Fail to get your IP Address at the moment.Please check your Network") os.system('pause') exit() # Finish getting IP hostname = socket.gethostname() AlertObj.Info("Hello %s user." % hostname, color=Alert.FOREGROUND_WHITE) AlertObj.Info("Your IPv4 Address: {}".format(ip)) # Get Location # Solution I location_url = 'http://freeapi.ipip.net/' r = requests.get(location_url + ip) # print(r.content.decode()) location = eval(r.content.decode())[0:3] # print(location) city = eval(r.content.decode())[2] ISP = eval(r.content.decode())[3] if '' in location: AlertObj.Warn('No City Info of your IP.') exit() AlertObj.Info( "============================================================",