#!/bin/python2.7 from HTMLParser import HTMLParser import httplib starttag = "" 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 starttag if tag == conf_temp: # starttag = tag for name, value in attrs: if name == "class" and value == "df-raw": print tag starttag = tag # pass #print starttag def handle_endtag(self, tag): global starttag if tag == "pre": starttag = "" def handle_data(self, data): #print starttag if starttag == conf_temp: print data conn = httplib.HTTPSConnection("www.whois.com") conn.request("GET", "/whois/ventraip.com.au") r1 = conn.getresponse() parser = MyHTMLParser() parser.feed(r1.read())