Skip to content

Commit

Permalink
Update ipicker.py
Browse files Browse the repository at this point in the history
- Code updation
  • Loading branch information
Deadpool2000 authored Nov 28, 2023
1 parent 78d0298 commit 7e39d4e
Showing 1 changed file with 108 additions and 96 deletions.
204 changes: 108 additions & 96 deletions ipicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,123 +10,135 @@
import urllib.request
import webbrowser
import os
try:
R='\033[91m'
Y='\033[93m'
G='\033[92m'
CY='\033[96m'
W='\033[97m'
path=os.path.isfile('/data/data/com.termux/files/usr/bin/bash')
def start():
os.system('clear')
print (CY+"""
_ ______ _ _
| (_____ (_) | |
| |_____) ) ____| | _ _____ ____
| | ____/ |/ ___) |_/ ) ___ |/ ___)
| | | | ( (___| _ (| ____| |
|_|_| |_|\____)_| \_)_____)_| """+Y+"""v1.1"""+G+"""
import sys

Simple IP Address locator
class IPAddressLocator:
def __init__(self):
self.R = '\033[91m'
self.Y = '\033[93m'
self.G = '\033[92m'
self.CY = '\033[96m'
self.W = '\033[97m'
self.path = os.path.isfile('/data/data/com.termux/files/usr/bin/bash')

"""+R+""">>"""+Y+"""----"""+CY+""" Author - Deadpool2000 """+Y+"""----"""+R+"""<<""")
def start(self):
os.system('clear')
print(self.CY + """
_ ______ _ _
| (_____ (_) | |
| |_____) ) ____| | _ _____ ____
| | ____/ |/ ___) |_/ ) ___ |/ ___)
| | | | ( (___| _ (| ____| |
|_|_| |_|\____)_| \_)_____)_| """ + self.Y + """v1.2""" + self.G + """
def m3():
try:
print(R+"""\n
#"""+Y+""" Select option"""+G+""" >>"""+Y+"""
Simple IP Address locator
""" + self.R + """>>""" + self.Y + """----""" + self.CY + """ Author - Deadpool2000 """ + self.Y + """----""" + self.R + """<<""")

1)"""+G+""" Check your IP info"""+Y+"""
2)"""+G+""" Check other IP info"""+Y+"""
3)"""+G+""" Exit
""")
ch=int(input(CY+"Enter Your choice: "+W))
if ch==1:
main2()
m3()
elif ch==2:
main()
m3()
elif ch==3:
print(Y+"Exit................"+W)
def m3(self):
try:
print(self.R + """\n
#""" + self.Y + """ Select option""" + self.G + """ >>""" + self.Y + """
1)""" + self.G + """ Check your IP info""" + self.Y + """
2)""" + self.G + """ Check other IP info""" + self.Y + """
3)""" + self.G + """ Exit
""")
ch = int(input(self.CY + "Enter Your choice: " + self.W))
if ch == 1:
self.main2()
self.m3()
elif ch == 2:
self.main()
self.m3()
elif ch == 3:
print(self.Y + "Exit................" + self.W)
sys.exit(0)
else:
print(R+"\nInvalid choice! Please try again\n")
m3()
print(self.R + "\nInvalid choice! Please try again\n")
self.m3()
except ValueError:
print(R+"\nInvalid choice! Please try again\n")
m3()
def finder(u):
print(self.R + "\nInvalid choice! Please try again\n")
self.m3()

def finder(self, u):
try:
try:
response = urllib.request.urlopen(u)
data = json.load(response)

print(R+"\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print(Y+'\n>>>'+CY+' IP address details\n ')
print(G+"1) IP Address : "+Y,data['query'],'\n')
print(G+"2) Org : "+Y,data['org'],'\n')
print(G+"3) City : "+Y,data['city'],'\n')
print(G+"4) Region : "+Y,data['regionName'],'\n')
print(G+"5) Country : "+Y,data['country'],'\n')
print(G+"6) Location\n")
print(G+"\tLattitude : "+Y,data['lat'],'\n')
print(G+"\tLongitude : "+Y,data['lon'],'\n')
l='https://www.google.com/maps/place/'+str(data['lat'])+'+'+str(data['lon'])
print(R+"\n#"+Y+" Google Map link : "+CY,l)
path=os.path.isfile('/data/data/com.termux/files/usr/bin/bash')
print(self.R + "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print(self.Y + '\n>>>' + self.CY + ' IP address details\n ')
print(self.G + "1) IP Address : " + self.Y, data['query'], '\n')
print(self.G + "2) Org : " + self.Y, data['org'], '\n')
print(self.G + "3) City : " + self.Y, data['city'], '\n')
print(self.G + "4) Region : " + self.Y, data['regionName'], '\n')
print(self.G + "5) Country : " + self.Y, data['country'], '\n')
print(self.G + "6) Location\n")
print(self.G + "\tLattitude : " + self.Y, data['lat'], '\n')
print(self.G + "\tLongitude : " + self.Y, data['lon'], '\n')
l = 'https://www.google.com/maps/place/' + str(data['lat']) + '+' + str(data['lon'])
print(self.R + "\n#" + self.Y + " Google Map link : " + self.CY, l)
path = os.path.isfile('/data/data/com.termux/files/usr/bin/bash')
if path:
link='am start -a android.intent.action.VIEW -d '+str(l)
pr=input(R+"\n>>"+Y+" Open link in browser?"+G+" (y|n): "+W)
if pr=="y":
lnk=str(link)+" > /dev/null"
link = 'am start -a android.intent.action.VIEW -d ' + str(l)
pr = input(self.R + "\n>>" + self.Y + " Open link in browser?" + self.G + " (y|n): " + self.W)
if pr == "y":
lnk = str(link) + " > /dev/null"
os.system(str(lnk))
start()
m3()
elif pr=="n":
self.start()
self.m3()
elif pr == "n":
print("\nCheck another IP or exit using Ctrl + C\n\n")
start()
m3()
self.start()
self.m3()
else:
print("\nInvalid choice! Please try again\n")
m3()
self.m3()
else:
pr=input(R+"\n>>"+Y+" Open link in browser?"+G+" (y|n): "+W)
if pr=="y":
webbrowser.open(l,new=0)
start()
m3()
elif pr=="n":
print(R+"\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print(Y+"\nCheck another IP or exit using "+R+"Ctrl + C\n\n")
start()
m3()
pr = input(self.R + "\n>>" + self.Y + " Open link in browser?" + self.G + " (y|n): " + self.W)
if pr == "y":
webbrowser.open(l, new=0)
self.start()
self.m3()
elif pr == "n":
print(self.R + "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print(self.Y + "\nCheck another IP or exit using " + self.R + "Ctrl + C\n\n")
self.start()
self.m3()
else:
print(R+"\nInvalid choice! Please try again\n")
m3()
print(self.R + "\nInvalid choice! Please try again\n")
self.m3()
return
except KeyError:
print(R+"\nError! Invalid IP/Website Address!\n"+W)
m3()
print(self.R + "\nError! Invalid IP/Website Address!\n" + self.W)
self.m3()
except urllib.error.URLError:
print(R+"\nError!"+Y+" Please check your internet connection!\n"+W)
print(self.R + "\nError!" + self.Y + " Please check your internet connection!\n" + self.W)
exit()


def main():
u=input(G+"\n>>> "+Y+"Enter IP Address/website address:"+W+" ")
if u=="":
print(R+"\nEnter valid IP Address/website address!")
main()
def main(self):
u = input(self.G + "\n>>> " + self.Y + "Enter IP Address/website address:" + self.W + " ")
if u == "":
print(self.R + "\nEnter valid IP Address/website address!")
self.main()
else:
url ='http://ip-api.com/json/'+u
finder(url)
def main2():
url ='http://ip-api.com/json/'
finder(url)

start()
m3()
except KeyboardInterrupt:
print(Y+"\nInterrupted ! Have a nice day :)"+W)
url = 'http://ip-api.com/json/' + u
self.finder(url)

def main2(self):
url = 'http://ip-api.com/json/'
self.finder(url)

def run(self):
try:
self.start()
self.m3()
except KeyboardInterrupt:
print(self.Y + "\nInterrupted! Have a nice day :)" + self.W)

if __name__ == "__main__":
ip_locator = IPAddressLocator()
ip_locator.run()

0 comments on commit 7e39d4e

Please sign in to comment.