Retrieving WHOIS Information Using Python

Python, Scripts, Websites - November 24, 2022 - 1 min read

Overview

What is WHOIS?

Whois is a popular Internet record listing that shows who owns a domain and how to contact them. Domain name registration and ownership are governed by the Internet Corporation for Assigned Names and Numbers (ICANN). Each Whois record will typically contain information such as the Registrant's (who owns the domain) name and contact information, the Registrar's (the organisation or commercial entity that registered the domain name), the registration dates, the name servers, the most recent update, and the expiration date.

Python program for extracting WHOIS information

Prepare your tools

We'll be using the whois module in Python. You can install this module using the pip command like this:

pip install python-whois

Python Code

from whois import whois

def extract(domainOrIp):
    w = whois(domainOrIp)
    return w

domainOrIp = input("Enter Domain Name or IP Address: ")
data = extract(domainOrIp)
print(data)

Output Screenshot

Tool Preview

Use our tool