Prerequisite: Python GUI – tkinter
In this article, we are going to see how to find IP from Domain Names and bind it with GUI Application using Python. We will use iplookup module for looking up IP from Domain Names. It is a small module which accepts a single domain as a string, or multiple domains as a list, and returns a list of associated IP.
Run this code into your terminal for installation.
pip install iplookup
Approach:
- Import module
- Create objects of iplookup
- Pass the domain into iplookup obj
- Now traverse the IP
Implementation:
Python3
from iplookup import iplookup
ip = iplookup.iplookup
domain = "geeksforgeeks.org"
result = ip(domain)
print ( "Domain name : " ,domain)
print ( "Ip : " ,result)
|
Output:
Domain name : geeksforgeeks.org
Ip : ['34.218.62.116']
IP lookup from domain GUI Application with Tkinter: This Script implements the above Implementation into a GUI.
Python3
from tkinter import *
from tkinter import messagebox
from iplookup import iplookup
def get_ip():
try :
ip = iplookup.iplookup
result = ip(e.get())
res. set (result)
except :
messagebox.showerror( "showerror" , "Something wrong" )
master = Tk()
master.configure(bg = 'light grey' )
res = StringVar()
Label(master, text = "Enter website name :" ,
bg = "light grey" ).grid(row = 0 , sticky = W)
Label(master, text = "Result :" , bg = "light grey" ).grid(row = 1 , sticky = W)
Label(master, text = " ", textvariable=res, bg=" light grey").grid(
row = 1 , column = 1 , sticky = W)
e = Entry(master)
e.grid(row = 0 , column = 1 )
b = Button(master, text = "Show" , command = get_ip)
b.grid(row = 0 , column = 2 , columnspan = 2 , rowspan = 2 , padx = 5 , pady = 5 )
mainloop()
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!