pieqq / pygeoipmap Goto Github PK
View Code? Open in Web Editor NEWLittle Python script to show where IP addresses are coming from by plotting them on a World map
License: MIT License
Little Python script to show where IP addresses are coming from by plotting them on a World map
License: MIT License
you can either do it through conda by
conda install -c https://conda.anaconda.org/anaconda basemap
or if in ubuntu through
sudo apt-get install python-mpltoolkits.basemap
I am trying to run this on a linux server that doesn't have a real display. I get the following error when trying to build the map.
_tkinter.TclError: no display name and no $DISPLAY environment variable
Is there any way to run this without a display?
Hi @Pierrrrrrre ,
very nice script thanks! It is very useful for reports! Unfortunately freegeoip is down now so the script does not work anymore. For this I have just hacked the script to include:
diff --git a/pygeoipmap.py b/pygeoipmap.py
index 2fddb0f..0b1816a 100644
--- a/pygeoipmap.py
+++ b/pygeoipmap.py
@@ -31,9 +31,10 @@ def get_lat_lon(ip_list=[], lats=[], lons=[]):
"""
print("Processing {} IPs...".format(len(ip_list)))
for ip in ip_list:
- r = requests.get("https://freegeoip.net/json/" + ip)
+ #r = requests.get("https://freegeoip.net/json/" + ip)
+ r = requests.get("https://www.telize.com/geoip/" + ip)
json_response = r.json()
- print("{ip}, {region_name}, {country_name}, {latitude}, {longitude}".format(**json_response))
+ print("{ip}, {continent_code}, {country}, {latitude}, {longitude}".format(**json_response))
if json_response['latitude'] and json_response['longitude']:
lats.append(json_response['latitude'])
lons.append(json_response['longitude'])
and use telize.com. I did not do a merge request because telize will shut down soon too .
Thanks again,
Denis
➜ PyGeoIpMap git:(master) ✗ sudo pip3 install -r requirements.txt
Collecting https://github.com/matplotlib/basemap/archive/v1.0.7rel.tar.gz (from -r requirements.txt (line 3))
Downloading https://github.com/matplotlib/basemap/archive/v1.0.7rel.tar.gz
| 164.3MB 16.0MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-req-build-gni68bkb/setup.py", line 1, in
import sys, glob, os, numpy, subprocess
ImportError: No module named 'numpy'----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-gni68bkb/
I think this will be sorted by moving numpy to one of the first packages to be installed.
Special characters returned from ipstack causes the script to fail.
ip: ""
hostname: ""
type: "ipv4"
continent_code: "AS"
continent_name: "Asia"
country_code: "SA"
country_name: "Saudi Arabia"
region_code: "01"
region_name: "Ar Riyāḑ"
city: "Riyadh"
zip: null
latitude: 24.6537
longitude: 46.7152
I put the script in/usr/local/bin with +chmod and it's happening again and again and I've Maxmind GeoLite2.csv , results.csv are IPs and I m a n00b , sorry for my errors :-)
$ pygeoipmap.py -i /root/results3.csv -o /tmp/output.png -f csv -s m --db /home/jhk/GeoLite2-City-Locations.csv
Traceback (most recent call last):
File "/usr/local/bin/pygeoipmap.py", line 124, in
main()
File "/usr/local/bin/pygeoipmap.py", line 118, in main
lats, lons = get_lat_lon_from_csv(args.input)
File "/usr/local/bin/pygeoipmap.py", line 77, in get_lat_lon_from_csv
lats.append(row[-2])
IndexError: list index out of range
I also did $ python pygeoipmap.py -i /root/results3.csv -o /tmp/output.png -f csv -s m --db /home/jhk/GeoLite2-City-Locations.csv
python: can't open file 'pygeoipmap.py': [Errno 2] No such file or directory
Thanks for a very useful script :)
I was wondering if its possible to add support for geoip2 or use it as a replacement for GeoIP?
Using geoip2.database one would be able to use the GeoLite2-City.mmdb database which has better accuracy.
Support for ipv6 addresses would be nice.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.