This python program is used to retrieve geolocation information of an IP address. You can use two methods to do this: the ipwhois package and the ipinfo package.
pip install -r requirements.txt
ipwhois is slow and provides limited data, but it does not require a user token and has no limit on the number of IP addresses that can be processed.
ipinfo is faster and provides more information, but it requires a user token and is limited to 50,000 IPs per month.
You need to create an account on ipinfo and get your API token if you want to use ipinfo. Before running the program, replace TOKEN_HERE with your ipinfo API token in the ipinfo_token variable.
This program reads IP addresses from a file named ip.txt, which should be present in the same directory as the python script. To add IP adresses, simply put them into the ip.txt file. The program will read each line as a unique IP address.
When the program is run, it asks whether you want to use ipwhois or ipinfo.
- Asks a series of questions about whether you want to create new save files and whether you want to print detailed information.
- Reads the IP addresses from ip.txt and retrieves geolocation information for each IP.
- Stores the results in several CSV files: ipwhois_save.csv (for valid IP addresses), ipwhois_error.csv (for IP addresses that couldn't be tracked), and ipwhois_detailed.csv (for detailed information about each IP address).
- Prints the results to the console.
- Asks whether you want to create a new save file.
- Reads the IP addresses from ip.txt and retrieves geolocation information for each IP.
- Stores the results in ipinfo_save.csv and prints the results while doing so.
The program has robust error handling. It checks if the API calls are successful. If not, it saves the errors along with the corresponding IP address for further investigation.
The provided ip.txt is a generated list made from this website: https://www.ipvoid.com/random-ip/