获取外部IP地址的实用程序
ipgetter2的Python项目详细描述
获取外部IP地址的实用程序。
此模块旨在从Internet获取外部IP地址。
它主要用于NAT之后。
它从服务器列表中随机选择您的IP,以最小化单个服务器上的请求开销
注意:这个库试图替代ipgetter库,因为那个库已经在pypi.org和github上消失了。
- 许可证:apache-2.0
- 文档:https://ipgetter2.readthedocs.io。
为什么还有另一个ipgetter库?
我发现伊普盖特在2019年5月11日晚上失踪了。我不知道它什么时候消失了,也不知道发生了什么。
所以我用同样的api接口为我的项目编写了这个库,希望它能帮助遇到同样情况的人。
功能
- 通过chardet正确检测网页编码
- 通过库控制超时请求而不是通过信号报警(报警信号将导致问题)
- 智能服务器获取算法,get()方法将在3个随机服务器中获取至少2个具有相同值的IP(只返回一个有效IP,不检查是否只有一个服务器响应)
- 也支持IPv6(如果服务器提供了两个值,则返回这两个值)
用法
- ipgetter2用法
>>> from ipgetter2 import IPGetter >>> getter = IPGetter() >>> getter.get() {v4:"8.8.8.8", v6:"::"} >>> getter.get_from("http://checkip.dyndns.org/plain") {v4:"8.8.8.8", v6:"::"} >>> getter.test() Numbers of Servers : 46 [1/46] Testing : http://ip.dnsexit.com [2/46] Testing : http://ifconfig.me/ip [3/46] Testing : http://ipecho.net/plain ...... [45/46] Testing : http://httpbin.org/ip [46/46] Testing : https://api.myip.com 8 server failed : ['http://checkip.dyndns.org/plain', 'http://www.canyouseeme.org/', 'http://whatsmyip.net/', 'http://www.ip-adress.com/', 'http://ip-lookup.net/', 'https://check.torproject.org/', 'https://www.privateinternetaccess.com/pages/whats-my-ip/', 'http://myexternalip.com/'] {IPAddress(v4="117.117.117.117", v6="::"): 26, IPAddress(v4="0.0.0.0", v6="::"): 11, IPAddress(v4="117.117.117.116", v6="::"): 1} IP's : {v4:"117.117.117.117", v6:"::"} = 26 ocurrencies
- ipgetter库的模拟api接口
>>> from ipgetter2 import ipgetter1 as ipgetter >>> myip = ipgetter.myip() >>> myip '8.8.8.8' >>> ipgetter.IPgetter().test() Number of servers: 47 IP's : 8.8.8.8 = 47 ocurrencies
1.1.9(2019-08-26)
- 修复了不使用python 3.5.x的问题
- 修复了在Windows上失败的测试
1.1.7(2019-05-25)
- 增加了更多服务器,主要来自中国
1.1.5(2019-05-25)
- 通过threading.thread加速get(),同时发送请求
1.1.1(2019-05-22)
- pypi上的第一个版本。