Created
October 12, 2016 03:24
-
-
Save vdchuyen/10b303b62011418eddc55b0206edff74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import csv | |
import requests | |
import re | |
import time | |
URL = 'http://api.hackertarget.com/whois/?q=' | |
''' | |
Create xxx file contain IP list, each IP one line. | |
23.27.250.128 | |
42.113.189.100 | |
116.108.228.128 | |
python whois.csv.py | |
''' | |
def whois_ip(ip): | |
r = requests.get(URL + ip) | |
netname = re.search(r'(netname|NetName).*', r.text) | |
if netname: | |
return netname.group(0) | |
# print whois_ip('74.125.204.26') | |
def main(): | |
ips = [ x[0] for x in csv.reader(open('xxx','r')) ] | |
for ip in ips: | |
print ip, whois_ip(ip) | |
time.sleep(1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment