"""Copy IP addresses to iplist.txt. Output will print IP addresses and ASN description which will be useful to find organization.
or we can use other key values as per our requirement"""
from ipwhois import IPWhois
iplist=open("iplist.txt","r")
iplistlines=iplist.readlines()
for ip in iplistlines:
ip=ip.strip()
try:
domaindetails=IPWhois(ip)
fulldetails=domaindetails.lookup_whois()
org=fulldetails.get('asn_description')
org=str(org)
print(ip+" "+org)
except:
print("Error Getting details of "+ip)