MCPcopy Create free account
hub / github.com/ActiveState/code / whois

Method whois

recipes/Python/577364_whois_client/recipe-577364.py:93–119  ·  view source on GitHub ↗

Perform initial lookup with TLD whois server then, if the quick flag is false, search that result for the region-specifc whois server and do a lookup there for contact details

(self, query, hostname, flags)

Source from the content-addressed store, hash-verified

91 return nhost
92
93 def whois(self, query, hostname, flags):
94 """Perform initial lookup with TLD whois server
95 then, if the quick flag is false, search that result
96 for the region-specifc whois server and do a lookup
97 there for contact details
98 """
99 #pdb.set_trace()
100 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
101 s.connect((hostname, 43))
102 if (hostname == NICClient.GERMNICHOST):
103 s.send("-T dn,ace -C US-ASCII " + query + "\r\n")
104 else:
105 s.send(query + "\r\n")
106 response = ''
107 while True:
108 d = s.recv(4096)
109 response += d
110 if not d:
111 break
112 s.close()
113 #pdb.set_trace()
114 nhost = None
115 if (flags & NICClient.WHOIS_RECURSE and nhost == None):
116 nhost = self.findwhois_server(response, hostname)
117 if (nhost != None):
118 response += self.whois(query, nhost, 0)
119 return response
120
121 def choose_server(self, domain):
122 """Choose initial lookup NIC host"""

Callers 1

whois_lookupMethod · 0.95

Calls 6

findwhois_serverMethod · 0.95
socketMethod · 0.80
connectMethod · 0.45
sendMethod · 0.45
recvMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected