├── .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 26 | 2. **Install Required Modules**:pip install phonenumbers folium opencage 27 | 3. **Setup API Key**: Save your OpenCage API key as an environment variable or modify the code to read it from a secure location. 28 | 29 | ## How to Use 30 | 31 | 1. Run the main script: python Tracker.py 32 | 2. Input the phone number with the country code when prompted. 33 | 3. If valid, the script will display the location and service provider. It will also generate an HTML file (`Location.html`) containing the map with the marked location. 34 | 35 | ## Screenshots 36 | 37 | ![Sample.png](Sample.png) 38 | 39 | ## Contributions 40 | 41 | Contributions, bug reports, and pull requests are welcome on GitHub at `https://github.com/Bisalkumar/Phone-Number-Tracker.git`. This project intends to be a safe, welcoming space for collaboration. 42 | 43 | ## License 44 | 45 | This project is licensed under the MIT License - see the `LICENSE.md` file for details. 46 | 47 | ## Acknowledgments 48 | 49 | - Thanks to the developers of `phonenumbers`, `folium`, and `opencage` for providing these excellent tools. 50 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiohttp==3.8.5 2 | aiosignal==1.3.1 3 | annotated-types==0.5.0 4 | async-timeout==4.0.3 5 | attrs==23.1.0 6 | backoff==2.2.1 7 | beautifulsoup4==4.12.2 8 | blinker==1.6.2 9 | blis==0.7.10 10 | branca==0.6.0 11 | breadability==0.1.20 12 | bs4==0.0.1 13 | cachetools==5.3.1 14 | catalogue==2.0.9 15 | certifi==2023.7.22 16 | chardet==5.2.0 17 | charset-normalizer==3.2.0 18 | click==8.1.7 19 | colorama==0.4.6 20 | comtypes==1.2.0 21 | confection==0.1.1 22 | contourpy==1.1.0 23 | cssselect==1.2.0 24 | cssutils==2.7.1 25 | cvzone==1.6.1 26 | cycler==0.11.0 27 | cymem==2.0.7 28 | decorator==4.4.2 29 | docopt==0.6.2 30 | Flask==2.3.3 31 | folium==0.14.0 32 | fonttools==4.42.0 33 | frozenlist==1.4.0 34 | gTTS==2.4.0 35 | idna==3.4 36 | imageio==2.31.3 37 | imageio-ffmpeg==0.4.9 38 | itsdangerous==2.1.2 39 | Jinja2==3.1.2 40 | joblib==1.3.2 41 | kiwisolver==1.4.4 42 | langcodes==3.3.0 43 | lxml==4.9.3 44 | MarkupSafe==2.1.3 45 | matplotlib==3.7.2 46 | moviepy==1.0.3 47 | multidict==6.0.4 48 | murmurhash==1.0.9 49 | networkx==3.1 50 | nltk==3.8.1 51 | numpy==1.25.2 52 | openai==0.27.9 53 | opencage==2.3.0 54 | opencv-python==4.8.0.76 55 | packaging==23.1 56 | pandas==2.1.1 57 | pathy==0.10.2 58 | phonenumbers==8.13.21 59 | Pillow==10.0.0 60 | premailer==3.10.0 61 | preshed==3.0.8 62 | proglog==0.1.10 63 | pycountry==22.3.5 64 | pydantic==2.2.1 65 | pydantic_core==2.6.1 66 | pygame==2.5.1 67 | pyparsing==3.0.9 68 | PyPDF2==3.0.1 69 | pypiwin32==223 70 | pypng==0.20220715.0 71 | PyQt5==5.15.9 72 | pyqt5-plugins==5.15.9.2.3 73 | PyQt5-Qt5==5.15.2 74 | PyQt5-sip==12.12.2 75 | pyqt5-tools==5.15.9.3.3 76 | python-dateutil==2.8.2 77 | python-dotenv==1.0.0 78 | pyttsx3==2.90 79 | pytz==2023.3.post1 80 | pywin32==306 81 | qrcode==7.4.2 82 | qt5-applications==5.15.2.2.3 83 | qt5-tools==5.15.2.1.3 84 | regex==2023.8.8 85 | requests==2.31.0 86 | scipy==1.11.1 87 | seaborn==0.13.0 88 | six==1.16.0 89 | smart-open==6.3.0 90 | soupsieve==2.4.1 91 | spacy==3.6.1 92 | spacy-legacy==3.0.12 93 | spacy-loggers==1.0.4 94 | SpeechRecognition==3.10.0 95 | srsly==2.4.7 96 | sumy==0.11.0 97 | thinc==8.1.12 98 | tqdm==4.66.1 99 | typer==0.9.0 100 | typing_extensions==4.7.1 101 | tzdata==2023.3 102 | urllib3==2.0.4 103 | wasabi==1.1.2 104 | Werkzeug==2.3.7 105 | xlrd==2.0.1 106 | yagmail==0.15.293 107 | yarl==1.9.2 108 | --------------------------------------------------------------------------------