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 urllib = future.moves.urllib.request
PY3K = version_info >= (3, 0) PY3K = version_info >= (3, 0)
__version__ = "0.6"
def myip(): def myip():
return IPgetter().get_external_ip() return IPgetter().get_external_ip()
@ -78,35 +81,30 @@ class IPgetter(object):
# 'https://www.privateinternetaccess.com/pages/whats-my-ip/', # 'https://www.privateinternetaccess.com/pages/whats-my-ip/',
# 'http://www.infosniper.net/', # 'http://www.infosniper.net/',
# 'http://ipinfo.io/', # 'http://ipinfo.io/',
g = IpGetter('http://ipinfo.io/ip', lambda x: x)
""" """
def __init__(self): def __init__(self):
self.server_list = [ self.server_list = [
'https://api.ipify.org', 'http://ifconfig.me/ip',
'https://ident.me', 'http://ipecho.net/plain',
'http://myip.dnsomatic.com', 'http://getmyipaddress.org/',
'https://checkip.amazonaws.com', 'http://www.my-ip-address.net/',
'http://ifconfig.me/ip', 'http://myexternalip.com/raw',
'http://ipecho.net/plain', 'http://www.canyouseeme.org/',
'http://getmyipaddress.org/', 'http://www.trackip.net/',
'http://www.my-ip-address.net/', 'http://icanhazip.com/',
'http://myexternalip.com/raw', 'http://www.ipchicken.com/',
'http://www.canyouseeme.org/', 'http://whatsmyip.net/',
'http://www.trackip.net/', 'http://www.lawrencegoetz.com/programs/ipinfo/',
'http://icanhazip.com/', 'http://ip-lookup.net/',
'http://www.ipchicken.com/', 'http://ipgoat.com/',
'http://whatsmyip.net/', 'http://www.myipnumber.com/my-ip-address.asp',
'http://www.lawrencegoetz.com/programs/ipinfo/', 'http://www.geoiptool.com/',
'http://ip-lookup.net/', 'http://checkip.dyndns.com/',
'http://ipgoat.com/', 'http://myexternalip.com/',
'http://www.myipnumber.com/my-ip-address.asp', 'http://www.ip-adress.eu/',
'http://www.geoiptool.com/', 'http://wtfismyip.com/',
'http://checkip.dyndns.com/', 'http://httpbin.org/ip',
'http://myexternalip.com/',
'http://www.ip-adress.eu/',
'http://wtfismyip.com/',
'http://httpbin.org/ip',
] ]
@ -129,10 +127,9 @@ class IPgetter(object):
continue continue
return '' return ''
def add_server(self, server, parser=None): def add_server(self, server, parser):
self.server_list.append(server) self.server_list.append(server)
if parser: self.parsers[server] = parser
self.parsers[server] = parser
def defaultparser(self, content): def defaultparser(self, content):
p = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(' p = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.('