ipwhoisを使ってwhoisで得られる情報を得る
ykishi@dezembro X-Forwarded-For % cat whois_test.py
#!/usr/bin/env python3
from ipwhois import IPWhois
import json
import sys
def get_info(ip):
obj = IPWhois(ip)
whoisInfo = obj.lookup_whois()
# print(type(whoisInfo))
name = whoisInfo["nets"][0]["name"]
country = whoisInfo["nets"][0]["country"]
return name, country
if __name__ == "__main__":
result = get_info("51.103.36.90")
print(type(result))
print(result)
print(",".join(result))
print(result[0])
print(result[1])
ykishi@dezembro X-Forwarded-For % ./whois_test.py
<class 'tuple'>
('MICROSOFT', 'GB')
MICROSOFT,GB
MICROSOFT
GB
ykishi@dezembro X-Forwarded-For %
Author And Source
この問題について(ipwhoisを使ってwhoisで得られる情報を得る), 我々は、より多くの情報をここで見つけました https://qiita.com/yaji_kita_on_the_way/items/31ada524cab6bf223ffe著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .