Last active
September 26, 2018 11:47
-
-
Save exoticknight/7f3bac7cf90b545cf2bf to your computer and use it in GitHub Desktop.
check whether the ip belongs to google using whois.
This file contains 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
import urllib2 | |
import json | |
raw_iplist= "193.92.133.35|74.125.131.34" | |
new_iplist = list() | |
not_iplist = list() | |
err_iplist = list() | |
for ip in raw_iplist.split("|"): | |
try: | |
response = json.load(urllib2.urlopen("http://adam.kahtava.com/services/whois.json?query=" + ip)) | |
if response["RegistryData"]["AdministrativeContact"]["Name"] != "Google Inc": | |
not_iplist.append(ip) | |
message = "no" | |
else: | |
new_iplist.append(ip) | |
message = "yes" | |
except Exception, e: | |
err_iplist.append(ip) | |
message = "error" | |
finally: | |
print("{ip}: {message}".format(ip=ip, message=message)) | |
def copy_to_clipboard( str ): | |
from Tkinter import Tk | |
r = Tk() | |
r.withdraw() | |
r.clipboard_clear() | |
r.clipboard_append( str ) | |
r.destroy() | |
copy_to_clipboard("|".join(new_iplist)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment