How to get phone number information using Python ?

prkskrs
Catalysts Reachout
Published in
Sep 2, 2022

In order to get details of any mobile number. We can use an inbuilt library of python i.e “phonenumbers”. And modules present inside this library are “geocoder”, “carrier” and “timezone”.

install the library “phonenumbers”

pip install phonenumbers

import library

import phonenumbers

take user’s phone number and parse it

a = input("Enter Phone Number: ")# Parsing
ph_no = phonenumbers.parse(a)

geocoder : this module is used to get the location of your number.

from phonenumbers import geocoder# Location Of Number
print(geocoder.description_for_number(ph_no,"en"))

carrier : this module is used to get the service_provider’s name of your number.

from phonenumbers import carrier# Service_Provider's Name
print(carrier.name_for_number(ph_no,"en"))

timezone : this module tells the timezone of the phone number.

from phonenumbers import timezone# Timezone
print(timezone.time_zones_for_number(ph_no))

Full Code: Link of code

--

--

prkskrs
Catalysts Reachout

backend developer and data scientist. currently studying computer science and constantly learning!