Thursday, 20 February 2014

IP location information

I made to have IP location information from IPs.

 import urllib  
   
 def iplocation(*data):  
   response = urllib.urlopen('http://api.hostip.info/get_html.php?ip='+ data[0]+'&position=true').read()  
   return response  
   
 iplists = open('iplists.txt','r')  
 save = open('result.csv', 'w')  
 for ip in iplists:  
   ip = str(ip).replace("\n","")  
   print " "*8 + "[-] " + ip  
   response = iplocation(ip)  
   response = response.split("\n")  
   county = response[0].split(":")  
   result = county[1].strip()  
   save.write(ip + ",\"" + result + "\"\n")  
   if result:  
     print " "*12 + result  
 iplists.close()  
 save.close()  
   

Put IPs into iplists.txt, then it makes result.csv.

No comments:

Post a Comment