DNS-py/HTTPy.py

46 lines
992 B
Python
Executable File

#!/bin/python2.7
from HTMLParser import HTMLParser
import httplib
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
conn = httplib.HTTPSConnection("www.whois.com")
conn.request("GET", "/whois/" + domain)
r1 = conn.getresponse()
parser = MyHTMLParser()
parser.feed(r1.read())