

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 two 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.
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 see : python advantages and disadvantage
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
Best of luck !!!
Also see following articles :
local variable referenced before assignment python unboundlocalerror