These are just two quick scripts I needed from time to time. Initially, I was searching for whois servers/websites then, I thought, maybe if I just write a quick script, that may save me some time. The results come in JSON format as we see in the screenshot above.So, here below are the scripts as I use them in Pycharm.This one is just a quick implementation of the whois tool:

# This is part of the python-whois module, you may want to
# uninstall the whois module and restart pycharm
#
import whois
my_domain = input("Please provide the domain name:")
my_result = whois.whois(my_domain)
print(my_result)
print('\n' + '-'*50 + '\n')

And this one is the IP whois:

# The module ipwhois may have to be installed
# Whois query port may have to be open in the firewall (port 43 tcp)
from ipwhois import IPWhois
from pprint import pprint

my_ip = input("Please provide the IP address: ")
my_result = IPWhois(my_ip)
# results = my_result.lookup_whois() # this is using the legacy whois port 43 tcp
results = my_result.lookup_rdap() # this is using the new whois - RDAP port 80 tcp

The above scripts were successfully tested using python 3.7.1, python-whois 0.7.1 and ipwhois 1.1.0