1. Python

WHOIS Domain LookUp Using Python

Python is a quite simple and powerful programming language in the sense that it can be applied to so many areas like Scientific Computing, Natural Language Processing but one specific area of application of Python which I found quite fascinating is => Doing Web Scraping Using Python.
In this article, I will discuss How to scrape WHOIS website to get information about specific websites using Python.
Let’s first talk about What actually is WHOIS? Its an Internet record listing that have information about who owns a Domain name, Domain Registration or Expiration Date and some other info as well.

who.is Domain Lookup Website

How to do WHOIS Domain Lookup using Python?

  1. Install Python Package python-whois-extended using python3 -m pip install python-whois-extended statement in terminal
  2. Import python-whois-extended package using import whois (Not import python-whois-extended)
  3. Pass Domain Name to whois.query(parameter) Function as a Parameter
  4. whois.query(parameter) Function will return a Domain Object
  5. Extract information about Domain Name from Domain Object by calling __dict__ function on it

Let’s put together all of these five steps as Python Code.

import whois
domain = whois.query('computersciencehub.io')

Below is an image showing above code’s output dictionary which contain Domain Name Information of website computersciencehub.io

Moreover in order to extract specific information like Registrar Name, Creation Date and so on, you can use Dictionary Indexing like Dictionary[registrar]. Let’s access specific information about a Domain Name using Python.
Below is python code for accessing specific information about a Domain Name using Python from WHOIS.

import whois
domain = whois.query('computersciencehub.io')
domain_info_dict = domain.__dict__

print("Domain Name Registrar is => ", domain_info_dict['registrar'])
print("Domain Name was register on => ", domain_info_dict['creation_date'])
print("Domain Name Status => ", domain_info_dict['status'])

Below is an image showing above code’s output => Specific Information about Domain Name of website computersciencehub.io

Getting Specific Information about Website using Python from WHOIS
Comments to: WHOIS Domain LookUp Using Python

Your email address will not be published.