Create a GUI to check Domain Availability using Tkinter
Last Updated :
09 Dec, 2021
There might be a case where a user wants to create a website and having certain ideas for the website’s name but is struck on their availability. So let’s develop a GUI that will check for domain availability. 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 the python-whois Module. To install this type the below command in the terminal.
pip install python-whois
After installation, let write code with examples.
Import the python-whois module and extracting information from the site
Python3
import whois
whois.whois( 'geeksforgeeks.com' )
|
Output:
If we are getting this type of information then it means this domain is registered for geeksforgeeks.
Now let’s write code for check domain availability.
Python3
import whois
import sys
try :
domain = whois.whois( "geeksforgeeks.com" )
if domain.domain_name = = None :
sys.exit( 1 )
except :
print ( "This domain is available" )
else :
print ( "Oops! this domain already purchased" )
|
Output:
Oops! this domain already purchased by GEEKSFORGEEKS.COM
Let’s check this on the domain site.
Checking myeeks.com domain availability.
Python3
domain = whois.whois( "myeeks.com" )
|
Output:
This domain is available
Let’s check this on the domain site.
Let’s create a GUI for the same using Tkinter.
Implementation:
Python3
from tkinter import *
import whois
import sys
def Domain_info():
try :
domain = whois.whois( str (e1.get()))
if domain.domain_name = = None :
sys.exit( 1 )
except :
result = "This domain is available"
else :
result = "Oops! this domain already purchased"
res. set (result)
master = Tk()
master.configure(bg = 'red' )
res = StringVar()
Label(master, text = "Website URL : " , bg = "red" ).grid(row = 0 , sticky = W)
Label(master, text = "Result :" , bg = "red" ).grid(row = 3 , sticky = W)
Label(master, text = " ", textvariable=res, bg=" red").grid(
row = 3 , column = 1 , sticky = W)
e1 = Entry(master)
e1.grid(row = 0 , column = 1 )
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
Share your thoughts in the comments
Please Login to comment...