Caller ID Lookup using Python
Last Updated :
08 Jul, 2021
Prerequisite :
In this article, we are going to see how we get Caller Id information using numverify API. Numverify offers a powerful tool to deliver phone number validation and information lookup in portable JSON format by Just making a request using a simple URL.
For the following program to work you must have an API key and to get one simply Click here.
Module needed:
- bs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not come built-in with Python. To install, type the following command in your terminal.
pip install bs4
- requests: Request allows you to send HTTP/1.1 requests extremely easily. This module also does not come built-in with Python. To install, type the following command in your terminal.
pip install requests
Approach:
- Import module
- Make a function for GET request
- Pass the URL with existing API key, mobile number, and country code
- Now retrieve the caller id information
Program:
Python3
import requests
import pandas as pd
from bs4 import BeautifulSoup
def getdata(url):
r = requests.get(url)
return r.text
api = 'YOUR API KEY'
number = '9852638787'
country = 'IN'
soup = BeautifulSoup(htmldata, 'html.parser' )
print (soup)
|
Output:
{
“valid”:true,
“number”:”919852638787″,
“local_format”:”09852638787″,
“international_format”:”+919852638787″,
“country_prefix”:”+91″,
“country_code”:”IN”,
“country_name”:”India (Republic of)”,
“location”:”Bihar”,
“carrier”:”Aircel Cellular Ltd”,
“line_type”:”mobile”
}
Share your thoughts in the comments
Please Login to comment...