This commit is contained in:
yumoqing 2023-06-22 11:09:15 +08:00
parent 3ff92f63a0
commit 3b96603b30

View File

@ -42,6 +42,9 @@ import future.moves.urllib.request
urllib = future.moves.urllib.request
PY3K = version_info >= (3, 0)
__version__ = "0.6"
def myip():
return IPgetter().get_external_ip()
@ -78,15 +81,10 @@ class IPgetter(object):
# 'https://www.privateinternetaccess.com/pages/whats-my-ip/',
# 'http://www.infosniper.net/',
# 'http://ipinfo.io/',
g = IpGetter('http://ipinfo.io/ip', lambda x: x)
"""
def __init__(self):
self.server_list = [
'https://api.ipify.org',
'https://ident.me',
'http://myip.dnsomatic.com',
'https://checkip.amazonaws.com',
'http://ifconfig.me/ip',
'http://ipecho.net/plain',
'http://getmyipaddress.org/',
@ -129,9 +127,8 @@ class IPgetter(object):
continue
return ''
def add_server(self, server, parser=None):
def add_server(self, server, parser):
self.server_list.append(server)
if parser:
self.parsers[server] = parser
def defaultparser(self, content):