For a personal project I’m conducting I want to use python to get the GPS location of a Phone number using python.
I tried to do that using the following code
import phonenumbers
from phonenumbers import geocoder, carrier
# Funzione per ottenere informazioni di base sul numero di telefono
def get_phone_info(phone_number):
try:
# Parse del numero di telefono
parsed_number = phonenumbers.parse(phone_number)
# Ottenere la regione (paese)
region = geocoder.description_for_number(parsed_number, "en")
# Ottenere il gestore del numero di telefono
phone_carrier = carrier.name_for_number(parsed_number, "en")
# Verificare se il numero è valido
valid = phonenumbers.is_valid_number(parsed_number)
return {
'valid': valid,
'region': region,
'carrier': phone_carrier,
'country_code': parsed_number.country_code,
'national_number': parsed_number.national_number
}
except phonenumbers.phonenumberutil.NumberParseException:
return {
'valid': False,
'region': None,
'carrier': None,
'country_code': None,
'national_number': None
}
# Esempio di utilizzo
if __name__ == "__main__":
phone_number ="PHONE_NUMBER" # Inserisci il numero di telefono da analizzare
phone_info = get_phone_info(phone_number)
if phone_info['valid']:
print(f"Country Code: {phone_info['country_code']}")
print(f"National Number: {phone_info['national_number']}")
print(f"Region: {phone_info['region']}")
print(f"Carrier: {phone_info['carrier']}")
else:
print("Invalid phone number")
I expected to get the, apart from the Country, the carrier and the number itself, the exact GPS postion or at least the region in which the number is located. Can anyone help me in achieving that?Thanks in advance 🙂