0

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 :)

2
  • Mobile phone numbers don't generally have a region encoded in them, landlines do but they are quite rare nowadays Commented Jun 2, 2024 at 13:27
  • 2
    If you could track the "exact GPS" of anyone's phone, that'd result in privacy concerns Commented Jun 2, 2024 at 13:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.