Welcome everyone, in this article you will learn How to trace mobile number and get information using python. Now a day there are so many application software is available to check the status of mobile users but it is also possible by using python script.
We are divided this article into five part :
Part 1: how you can get the information about phone number like the network service provider name of that phone number
Part 2 : How to trace mobile number and get information using python like country name to which the phone number belongs to.
Part 3: How to create free phone number tracker app using python
part 4: How to find mobile number or phone number in python using simple way
part5: How do I find phone number details in python?
Table of Contents
How you can get the information about phone number like network service provider name of that phone number.
Installation of required module :
It must need to import phonenumbers module for this task.How to import this module ..? By using the below command in your command prompt.
pip install phonenumbers
Write the python script to get the service provider name to that phone number
Also check: python best ecommerce library
Example 1: Python program to get the service provider name to that phone number
import phonenumbers
# service provider of required phone number
from phonenumbers import carrier
service_provider = phonenumbers.parse("Number with country code")
# Indian phone number example: +91743*******
# Pakistan phone number example: +92765*********
# this code will print the service provider name like vodaphone idea JIO
print(carrier.name_for_number(service_provider, 'en'))
OUTPUT :
JIO
Example 2: Python script to get the country name to which phone number belongs:
import phonenumbers
# country location to that phone number
from phonenumbers import geocoder
phone_number = phonenumbers.parse("Number with country code")
# Indian phone number example: +91789********
# Pakistan phone number example: +92876********
# then this will print the country name
print(geocoder.description_for_number(phone_number, 'en'))
OUTPUT:
INDIAN
How to trace mobile number and get information using python like country name to which the phone number belongs to.
This is second part of the our article, here I will explain you How to trace mobile number and get information using python like country name to which the phone number belongs to.
How to trace mobile number location
Follow the following steps
- #1 we need to initialize the mechanize browser object.
- #2 we select the form which I need to enter the targeted mobile number and submit the values to the form.
- #3 we need to provide a mobile number which you want trace the details of the mobile number.
- #4 and then initialized the soup object and pass res object and parser.
- #5 After the initialized the soup object we submit the phone number to the form it will get the details from the server.
- #6 we collect the necessary data from the table and print them on the command prompt.
- #7 Finally executing the above script we will got the details of a phone number
For the trace mobile number location you need to import two libraries or packages
pip install beautifulsoup4 #Beautifusoup libraries
pip install mechanize #Mechanize libraries
# import libraries
from bs4 import BeautifulSoup
import mechanize
mc = mechanize.Browser()
mc.set_handle_robots(False)
url = 'https://www.findandtrace.com/trace-mobile-number-location'
mc.open(url)
mc.select_form(name='trace')
mc['mobilenumber'] = '' # Enter a targeted mobile number
res = mc.submit().read()
soup = BeautifulSoup(res,'html.parser')
tbl = soup.find_all('table',class_='shop_table')
#print(tbl)
data = tbl[0].find('tfoot')
c=0
for i in data:
c+=1
if c in (1,4,6,8):
continue
th = i.find('th')
td = i.find('td')
print(th.text,td.text)
data = tbl[1].find('tfoot')
c=0
for i in data:
c+=1
if c in (2,20,22,26):
th = i.find('th')
td = i.find('td')
print(th.text,td.text)
Summary :
So finally friends we saw How to trace mobile number and get information using python. If about this section any query then please comment me.
post : python online compiler
Also see following articles :
local variable referenced before assignment python unboundlocalerror
python trending terminology course ebook
How to create free phone number tracker app using python
Hello everyone, in the previouse section we saw How to trace mobile number using python, in this section we will learn How to create free python app using python.
It’s a very basic and simple app to user because it provide userfriendly interface.
So you need to have the some basics of Python code to be able to complete this app.
Step 1: Some Requirements for create App phone number tracker app
phone-iso3166
Tkinter
pycountry
Explanation :
First We are going to use phone-iso3166 libraries to determine the get alpha_2 letters of the country from the given number and pycountry to determine the official name of the country or region using alpha_2 letters we obtained from phone-iso3166.
Sample code :
>>> import pycountry
>>> from phone_iso3166.country import phone_country
>>> code = phone_country("8999447***")
>>> code
'TZ'
>>> pycountry.countries.get(alpha_2 = code)
Country(alpha_2='TZ', alpha_3='TZA', common_name='Tanzania', name='Tanzania, United Republic of', numeric='834', official_name='United Republic of Tanzania')
>>>
So from above example we well know how to get country information from a phone number, next step is We need to put our logic code in a formation of an App so as we can easily use it.
from the above reference Below is a code of the skeleton for our GUI app
Step 2 : Python code for create free phone number tracker app
import json
import pycountry
from tkinter import Tk, Label, Button, Entry
from phone_iso3166.country import phone_country
class Location_Tracker:
def __init__(self, App):
self.window = App
self.window.title("free Phone number Tracker app")
self.window.geometry("500x400")
self.window.configure(bg="#3f5efb")
self.window.resizable(False, False)
#___________Application menu_____________
Label(App, text="Enter a phone number",fg="white", font=("Times", 20), bg="#3f5efb").place(x=150,y= 30)
self.phone_number = Entry(App, width=16, font=("Arial", 15), relief="flat")
self.track_button = Button(App, text="Track Country", bg="#22c1c3", relief="sunken")
self.country_label = Label(App,fg="white", font=("Times", 20), bg="#3f5efb")
#___________Place widgets on the window______
self.phone_number.place(x=170, y=120)
self.track_button.place(x=200, y=200)
self.country_label.place(x=100, y=280)
#__________Linking button with countries ________
self.track_button.bind("<Button-1>", self.Track_location)
#255757294146
def Track_location(self,event):
phone_number = self.phone_number.get()
country = "Country is Unknown"
if phone_number:
tracked = pycountry.countries.get(alpha_2=phone_country(phone_number))
print(tracked)
if tracked:
country = tracked.official_name
self.country_label.configure(text=country)
PhoneTracker = Tk()
MyApp = Location_Tracker(PhoneTracker)
PhoneTracker.mainloop()
Step 3 : Enter the phone number for test the app
After the run following code output will look like this.
part 4: How to find mobile number or phone number in python using simple way
if Above code is not working then you can also try this source code i hope this help full for you.
Step 1st: To start executing this tutorial on How To find mobile or phone number Using Python With Source Code, for that make sure that you have installed Python 3.9 and PyCharm .
Step 2nd : You need to Import following library
import json ## json import
import pycountry ## pycountry import
from tkinter import Tk, Label, Button, Entry
from phone_iso3166.country import phone_country
Step 3rd: Use following source code
### After adding above library you need to use following source code ###
class Location_Tracker:
def __init__(self, App):
self.window = App
self.window.title("Phone number Tracker App")
self.window.geometry("500x400")
self.window.configure(bg="#3f5efb")
self.window.resizable(False, False)
#___________Application menu_____________
Label(App, text="Enter a phone number",fg="white", font=("Times", 20), bg="#3f5efb").place(x=150,y= 30)
self.phone_number = Entry(App, width=16, font=("Arial", 15), relief="flat")
self.track_button = Button(App, text="Track Country", bg="#22c1c3", relief="sunken")
self.country_label = Label(App,fg="white", font=("Times", 20), bg="#3f5efb")
#___________Place widgets on the window______
self.phone_number.place(x=170, y=120)
self.track_button.place(x=200, y=200)
self.country_label.place(x=100, y=280)
#__________Linking button with countries ________
self.track_button.bind("<Button-1>", self.Track_location)
#255757294146
def Track_location(self,event):
phone_number = self.phone_number.get()
country = "Country is Unknown"
if phone_number:
tracked = pycountry.countries.get(alpha_2=phone_country(phone_number))
print(tracked)
if tracked:
if hasattr(tracked, "official_name"):
country = tracked.official_name
else:
country = tracked.name
self.country_label.configure(text=country)
PhoneTracker = Tk()
MyApp = Location_Tracker(PhoneTracker)
PhoneTracker.mainloop()
After run this code one pop-up windows shown and you need to enter mobile number in it.
How do I find phone number details in python?
There are several ways to find phone number details in Python, but one common approach is to use a third-party library such as phonenumbers.
Here’s an example of how to use phone numbers to find phone number details:
- Install phone numbers library using pip:
pip install phonenumbers
- Import the phonenumbers module and parse the phone number:
import phonenumbers
phone_number = "+14155552671" # Replace with the phone number you want to look up
parsed_number = phonenumbers.parse(phone_number, "US")
- Get the phone number details:
print(parsed_number.country_code) # Prints the country code (1 for US)
print(parsed_number.national_number) # Prints the national number (4155552671 for US)
print(phonenumbers.format_number(parsed_number, phonenumbers.PhoneNumberFormat.INTERNATIONAL)) # Prints the formatted phone number in international format (+1 415-555-2671)
print(phonenumbers.is_valid_number(parsed_number)) # Prints whether the phone number is valid (True for US number)
print(phonenumbers.is_possible_number(parsed_number)) # Prints whether the phone number is possible (True for US number)
This should give you a basic understanding of how to find phone number details using phonenumbers in Python. Note that this library supports many different phone number formats and regions, so be sure to read the documentation for more information.
1. Can I track a phone number using Python?
It’s not possible to get the exact location of a phone number using only Python. However, you can use APIs provided by location-based services to get an approximate location of the phone based on the cell tower it is connected to or the GPS coordinates if it is enabled.
Here’s an example code using the Google Maps API to get the approximate location of a phone number:
import requests
def get_location(phone_number):
url = “https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY”
headers = {“Content-Type”: “application/json”}data = { "considerIp": "false", "wifiAccessPoints": [], "cellTowers": [ { "cellId": 42, "locationAreaCode": 415, "mobileCountryCode": 310, "mobileNetworkCode": 410, "age": 0, "signalStrength": -60, "timingAdvance": 15 } ] } response = requests.post(url, headers=headers, json=data) if response.status_code == 200: json_data = response.json() location = json_data.get('location', {}) latitude = location.get('lat', 0) longitude = location.get('lng', 0) accuracy = json_data.get('accuracy', 0) return {"latitude": latitude, "longitude": longitude, "accuracy": accuracy} else: return None
Example usage:
phone_number = “+1234567890”
location = get_location(phone_number)
print(location)
Note that in order to use the Google Maps API, you need to sign up for a free API key and include it in the url variable. Additionally, this code only provides an approximate location based on the cell tower information and is not guaranteed to be accurate.
Also Read