本文整理汇总了Python中ipwhois.IPWhois.lookup_rws方法的典型用法代码示例。如果您正苦于以下问题:Python IPWhois.lookup_rws方法的具体用法?Python IPWhois.lookup_rws怎么用?Python IPWhois.lookup_rws使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipwhois.IPWhois
的用法示例。
在下文中一共展示了IPWhois.lookup_rws方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lookup_rws
# 需要导入模块: from ipwhois import IPWhois [as 别名]
# 或者: from ipwhois.IPWhois import lookup_rws [as 别名]
def test_lookup_rws(self):
try:
from urllib.request import ProxyHandler, build_opener
except ImportError:
from urllib2 import ProxyHandler, build_opener
ips = [
'74.125.225.229', # ARIN
'2001:4860:4860::8888',
'62.239.237.1', # RIPE
'2a00:2381:ffff::1',
'210.107.73.73', # APNIC
'2001:240:10c:1::ca20:9d1d',
'200.57.141.161', # LACNIC
'2801:10:c000::',
'196.11.240.215', # AFRINIC
'2001:43f8:7b0::'
]
for ip in ips:
result = IPWhois(ip)
try:
self.assertIsInstance(result.lookup_rws(), dict)
except (ASNLookupError, ASNRegistryError, WhoisLookupError):
pass
except AssertionError as e:
raise e
except Exception as e:
self.fail('Unexpected exception raised: %r' % e)
handler = ProxyHandler({'http': 'http://0.0.0.0:80/'})
opener = build_opener(handler)
result = IPWhois('74.125.225.229', 0, opener)
self.assertRaises(WhoisLookupError, result.lookup_rws)
示例2: gather
# 需要导入模块: from ipwhois import IPWhois [as 别名]
# 或者: from ipwhois.IPWhois import lookup_rws [as 别名]
def gather(self, all_ips):
for path, incoming_ip_obj in all_ips.iteritems():
if incoming_ip_obj[0].ip_whois == "":
try:
print "Gathering whois information about " + incoming_ip_obj[0].ip_address
ip_whois = IPWhois(incoming_ip_obj[0].ip_address)
incoming_ip_obj[0].ip_whois = ip_whois.lookup_rws()
except IPDefinedError:
print helpers.color("[*] Error: Private IP address, skipping IP!", warning=True)
return
示例3: test_lookup_rws
# 需要导入模块: from ipwhois import IPWhois [as 别名]
# 或者: from ipwhois.IPWhois import lookup_rws [as 别名]
def test_lookup_rws(self):
from urllib import request
result = IPWhois('74.125.225.229')
try:
self.assertIsInstance(result.lookup_rws(), dict)
except (ASNLookupError, WhoisLookupError):
pass
except AssertionError as e:
raise e
except Exception as e:
self.fail('Unexpected exception raised: %r' % e)
handler = request.ProxyHandler({'http': 'http://0.0.0.0:80/'})
opener = request.build_opener(handler)
result = IPWhois('74.125.225.229', 0, opener)
self.assertRaises(WhoisLookupError, result.lookup_rws)