69 lines
1.5 KiB
Python
Executable File
69 lines
1.5 KiB
Python
Executable File
#!/bin/python2.7
|
|
#Loockup jsonWhois.com, easy json API for whois lookups ;D
|
|
#Might need to run this in windows/on laptop/ in VM
|
|
|
|
from HTMLParser import HTMLParser
|
|
import httplib
|
|
import argparse
|
|
import subprocess
|
|
|
|
|
|
#Make this work with linux magic
|
|
|
|
count = 0
|
|
|
|
currtag = ""
|
|
conf_temp = "pre"
|
|
#URL https://www.whois.com/whois/benjamyn-testing.com
|
|
#class df-block-raw
|
|
|
|
|
|
|
|
class MyHTMLParser(HTMLParser):
|
|
def handle_starttag(self, tag, attrs):
|
|
global conf_temp
|
|
global currtag
|
|
if tag == conf_temp:
|
|
# starttag = tag
|
|
for name, value in attrs:
|
|
if name == "class" and value == "df-raw":
|
|
print tag
|
|
currtag = tag
|
|
# pass
|
|
#print starttag
|
|
|
|
def handle_endtag(self, tag):
|
|
global currtag
|
|
if tag == "pre":
|
|
currtag = ""
|
|
|
|
def handle_data(self, data):
|
|
#print starttag
|
|
if currtag == conf_temp:
|
|
print data
|
|
|
|
domain = raw_input("Enter a domain: ")
|
|
print domain
|
|
partDomain = domain.partition(".")
|
|
print partDomain
|
|
#if partDomain[2] != "":
|
|
#run code
|
|
#else tell user they suck :D
|
|
|
|
lookup = subprocess.check_output(["whois", domain])
|
|
print "========================================================"
|
|
test = lookup.split("\n")
|
|
|
|
while count != len(test):
|
|
print count, test[count]
|
|
count = count + 1
|
|
|
|
#conn = httplib.HTTPSConnection("www.whois.com")
|
|
#conn.request("GET", "/whois/" + domain)
|
|
#r1 = conn.getresponse()
|
|
#parser = MyHTMLParser()
|
|
|
|
#parser.feed(r1.read())
|
|
|
|
|