Python 3 Script to Get Mobile Number Country Name and Service Provider Information Using phonenumbers Module Full Project For Beginners

 

 

In order to get started you need to install the below library using the pip command as shown below

 

 

pip install phonenumbers

 

 

After installing this library you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

Get Country Name of Mobile Number

 

 

import phonenumbers

# geocoder: to know the specific
# location to that phone number
from phonenumbers import geocoder


phone_number = phonenumbers.parse("Number with country code")
# Indian phone number example: +91**********
# Nepali phone number example: +977**********

    
# this will print the country name
print(geocoder.description_for_number(phone_number,
                                    'en'))

 

 

 

Get Service Provider of Mobile Number

 

 

 

import phonenumbers

# carrier: to know the name of
# service provider of that phone number
from phonenumbers import carrier


service_provider = phonenumbers.parse("Number with country code")
# Indian phone number example: +91**********
# Nepali phone number example: +977**********

    
# this will print the service provider name
print(carrier.name_for_number(service_provider,
                            'en'))

 

Leave a Reply