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
+25.2k Golang : How to read integer value from standard input ?
+13.6k Golang : Get current time
+29.2k Golang : Get time.Duration in year, month, week or day
+5.4k Cash Flow : 50 days to pay your credit card debt
+6.8k Golang : Array mapping with Interface
+9.8k Golang : How to tokenize source code with text/scanner package?
+7.4k Golang : Getting Echo framework StartAutoTLS to work
+12.3k Golang : Pass database connection to function called from another package and HTTP Handler
+16.9k Golang : Get future or past hours, minutes or seconds
+7.6k Swift : Convert (cast) String to Float
+6.7k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+11.2k Golang : Surveillance with web camera and OpenCV