[go: up one dir, main page]

0% found this document useful (0 votes)
3 views1 page

Phone Search - Py

The document contains a Python function that tracks the location of an Android phone using its phone number. It validates the phone number and checks if it belongs to an Android device before retrieving its geographic coordinates and reverse geocoding them to obtain the location. If the phone number is invalid or not associated with an Android device, it outputs an error message.

Uploaded by

tjpoisal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Phone Search - Py

The document contains a Python function that tracks the location of an Android phone using its phone number. It validates the phone number and checks if it belongs to an Android device before retrieving its geographic coordinates and reverse geocoding them to obtain the location. If the phone number is invalid or not associated with an Android device, it outputs an error message.

Uploaded by

tjpoisal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

import phonenumbers

from phonenumbers import geocoder


from geopy.geocoders import Nominatim

def track_android_phone_location(phone_number):
# Parse the phone number
parsed_number = phonenumbers.parse(phone_number, "US")

# Check if the phone number is valid and belongs to an Android device


if phonenumbers.is_valid_number(parsed_number) and
phonenumbers.carrier.name_for_number(parsed_number, "en") == "Android":
# Get the latitude and longitude coordinates
latitude = parsed_number.latitude
longitude = parsed_number.longitude

# Reverse geocode the coordinates to get the location


geolocator = Nominatim(user_agent="android_phone_tracker")
location = geolocator.reverse(f"{latitude}, {longitude}")

# Print the location information


print(f"Location: {location.address}")
else:
print("Invalid phone number or not an Android device.")

# Example usage
android_phone_number = "5714217839" # Replace with the actual Android phone
number
track_android_phone_location(android_phone_number)

You might also like