Python : Create Whois client or function example
Adding this Python tutorial as a supplement for my previous tutorial on how to implement Golang whois client.
Whois a network utility to find out "who is" the owner behind a domain name. Some owners will display all the private information such as personal home address, mobile/cell phone numbers and while some will choose to protect their privacy.
Here is an example on how to implement whois query in Python :
import sys
import socket
def whois(domainName, server):
# dial to whois server port 43
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
conn.connect((server, 43))
# send query over conn
conn.send((domainName + "\r\n").encode())
result = b""
while True:
buf = conn.recv(1024)
result += buf
if not buf:
break
conn.close()
return result
result = whois("socketloop.com", "com.whois-servers.net")
print(result.decode())
Hope this helps!
References :
See also : Golang : Whois examples
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+22.2k Golang : Repeat a character by multiple of x factor
+6.2k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+15.4k Golang : Accurate and reliable decimal calculations
+31.8k Golang : How to convert(cast) string to IP address?
+41.3k Golang : How to count duplicate items in slice/array?
+16.2k Golang : How to check if input from os.Args is integer?
+11.4k Golang : How to pipe input data to executing child process?
+7.8k Golang : Command line ticker to show work in progress
+6.2k Golang : Get missing location after unmarshal binary and gob decode time.
+12.1k Golang : Convert a rune to unicode style string \u
+6.9k Golang : Find the longest line of text example
+9.8k Golang : Detect number of active displays and the display's resolution