Open In App

Create a GUI to Get Domain Information Using Tkinter

Last Updated : 07 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisites: Python GUI – tkinter

Domain information is very important for every user. It contains information like Name, organization, State, city, Ip address, emails, server name, etc. In this article, we will write code for getting domain information and bind it with GUI Application. We will use the Python-whois module to get information about the website. It’s able to extract data for all the popular TLDs (com, org, net, …)

Installation

Before writing the code we need to install python-whois Module. To install this type the below command in the terminal.

pip install python-whois

After installation, let understands this module with examples.

Step 1: Import python-whois module

Python3




import whois


Step 2: Use whois.whois( ) methods to get all information.

Python3




whois.whois('geeksforgeeks.com')


Output:

Step 3: Let’s, extract some importation data from the geeksforgeeks.com site.

Python3




domain = whois.whois('geeksforgeeks.com')
print("Expiration Date :",domain.expiration_date)
print("Email :", domain.emails)
print("Server name : ",domain.name_servers)


Output:

Expiration Date : 2025-06-06 18:16:43
Email : abuse@uniregistry.com
Server name :  ['NS1.PARKINGCREW.NET', 'NS2.PARKINGCREW.NET']

Let’s create a GUI for the above code using tkinter.

Implementation:

Python3




# import modules
from tkinter import *
import whois
 
 
# user define function
# for get domain information
def Domain_info():
    domain = whois.whois(str(e1.get()))
    server.set(domain.whois_server)
    exp_date.set(domain.expiration_date)
    reg_name.set(domain.name)
    org.set(domain.org)
    state.set(domain.state)
    city.set(domain.city)
    country.set(domain.country)
 
 
# object of tkinter
# and background set for red
master = Tk()
master.configure(bg='red')
 
# Variable Classes in tkinter
server = StringVar()
exp_date = StringVar()
reg_name = StringVar()
org = StringVar()
state = StringVar()
city = StringVar()
country = StringVar()
 
# Creating label for each information
# name using widget Label
Label(master, text="Website URL : ", bg="red").grid(row=0, sticky=W)
Label(master, text="Server Name :", bg="red").grid(row=3, sticky=W)
Label(master, text="Expiration date :", bg="red").grid(row=4, sticky=W)
Label(master, text="Register name :", bg="red").grid(row=5, sticky=W)
Label(master, text="Origination :", bg="red").grid(row=6, sticky=W)
Label(master, text="State :", bg="red").grid(row=7, sticky=W)
Label(master, text="City :", bg="red").grid(row=8, sticky=W)
Label(master, text="Country :", bg="red").grid(row=9, sticky=W)
 
# Creating label for class variable
# name using widget Entry
Label(master, text="", textvariable=server,
      bg="red").grid(row=3, column=1, sticky=W)
Label(master, text="", textvariable=exp_date,
      bg="red").grid(row=4, column=1, sticky=W)
Label(master, text="", textvariable=reg_name,
      bg="red").grid(row=5, column=1, sticky=W)
Label(master, text="", textvariable=org, bg="red").grid(
    row=6, column=1, sticky=W)
Label(master, text="", textvariable=state,
      bg="red").grid(row=7, column=1, sticky=W)
Label(master, text="", textvariable=city,
      bg="red").grid(row=8, column=1, sticky=W)
Label(master, text="", textvariable=country,
      bg="red").grid(row=9, column=1, sticky=W)
 
 
e1 = Entry(master)
e1.grid(row=0, column=1)
 
# creating a button using the widget
# Button that will call the submit function
b = Button(master, text="Show", command=Domain_info, bg="Blue")
b.grid(row=0, column=2, columnspan=2, rowspan=2, padx=5, pady=5,)
 
mainloop()


Output:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads