├── .gitignore ├── LICENSE ├── Location.html ├── Sample.png ├── Tracker.py ├── config.env ├── readme.md └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | venv/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Bisal Kumar Sahoo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Location.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 90 | -------------------------------------------------------------------------------- /Sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bisalkumar/Phone-Number-Tracker/bc6a82c592cf8c5e853de953c6bbd7cfaefdfb63/Sample.png -------------------------------------------------------------------------------- /Tracker.py: -------------------------------------------------------------------------------- 1 | import os 2 | from dotenv import load_dotenv 3 | import phonenumbers 4 | from phonenumbers import geocoder, carrier 5 | import folium 6 | from opencage.geocoder import OpenCageGeocode 7 | 8 | def get_location_and_service_provider(phone_number): 9 | try: 10 | parsed_number = phonenumbers.parse(phone_number) 11 | location = geocoder.description_for_number(parsed_number, "en") 12 | service_provider = carrier.name_for_number(parsed_number, "en") 13 | return location, service_provider 14 | except: 15 | return None, None 16 | 17 | def get_lat_lng(location, api_key): 18 | geocoder_api = OpenCageGeocode(api_key) 19 | results = geocoder_api.geocode(location) 20 | if results: 21 | return results[0]['geometry']['lat'], results[0]['geometry']['lng'] 22 | return None, None 23 | 24 | def generate_map(lat, lng, location_name): 25 | my_map = folium.Map(location=[lat, lng], zoom_start=9) 26 | folium.Marker([lat, lng], popup=location_name).add_to(my_map) 27 | my_map.save("Location.html") 28 | 29 | def main(): 30 | # Load environment variables from config.env file 31 | load_dotenv() 32 | 33 | API_KEY = os.getenv("OPENCAGE_API_KEY") 34 | if not API_KEY: 35 | print("Error: API key not found in environment variables.") 36 | return 37 | 38 | phone_number = input("Enter the PhoneNumber with the country code : ") 39 | 40 | location, service_provider = get_location_and_service_provider(phone_number) 41 | if not location: 42 | print("Invalid phone number or unable to fetch location.") 43 | return 44 | 45 | print(f"Location: {location}") 46 | print(f"Service Provider: {service_provider}") 47 | 48 | lat, lng = get_lat_lng(location, API_KEY) 49 | if not lat or not lng: 50 | print("Unable to get latitude and longitude for the location.") 51 | return 52 | 53 | generate_map(lat, lng, location) 54 | 55 | if __name__ == "__main__": 56 | main() 57 | -------------------------------------------------------------------------------- /config.env: -------------------------------------------------------------------------------- 1 | OPENCAGE_API_KEY=11e0d6f8fd894f3e872d8aca6500a572 2 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # PhoneNumber Geolocation and Service Provider Finder 2 | 3 | This tool fetches the geographical location and service provider of a phone number and plots that location on a map using the Folium library. 4 | 5 | ## Details 6 | 7 | To make this tool work, several Python modules need to be installed. They provide functionalities like parsing phone numbers, geocoding, and map generation. 8 | 9 | ### Modules to be installed: 10 | 11 | - `phonenumbers` 12 | - `folium` 13 | - `opencage` 14 | 15 | You can install these modules using: pip install phonenumbers folium opencage 16 | 17 | ## Features 18 | 19 | 1. **Phone Number Parsing**: Detects the location and service provider associated with a given phone number. 20 | 2. **Geocoding**: Converts a location name to its corresponding latitude and longitude using the OpenCage Geocoding API. 21 | 3. **Map Generation**: Creates an interactive map marking the location. 22 | 23 | ## Getting Started 24 | 25 | 1. **Clone the Repository**: git clone