GeoLocationIp is an advanced IP geolocation tool written in Python. It consults ip-api.com to retrieve geographic information for one or more IPs. It supports querying a single IP, multiple IPs, or batch processing via a text file, and can output results in multiple formats including a text table, JSON, and CSV.
- No external dependencies: Uses only the Python 3 standard library.
- Multiple output formats: Table (default), JSON, and CSV.
- Batch processing: Read multiple IPs from a text file.
- Validation: Automatically validates IPs (IPv4 and IPv6) before querying.
- Python 3.7 or higher
No external libraries are required.
You can run the script from the command line. Below are some examples:
python ip_locator.py 8.8.8.8python ip_locator.py 1.1.1.1 8.8.8.8python ip_locator.py 8.8.8.8 --output jsonCreate a text file (e.g., ips.txt) with one IP per line. Then run:
python ip_locator.py --batch ips.txt --output csv > report.csvips: One or more IP addresses to look up.-b, --batch <file>: Text file with one IP per line.-o, --output <format>: Output format. Options:table,json,csv. (Default:table)-t, --timeout <seconds>: Request timeout in seconds. (Default: 15)--no-warnings: Suppress warnings (e.g., private IP notices).-h, --help: Show help message and exit.
IP geolocation relies on public ISP databases. Precision is usually limited to the city or ISP datacenter level.