使用Basemap绘制vpngate.net 地图
使用Basemap绘制vpngate.net 地图
Intro
导入一波需要用的
import sys
from mpl_toolkits.basemap import Basemap
from geolite2 import geolite2
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
read = geolite2.reader()
%matplotlib inline
map = Basemap(
projection='merc', llcrnrlon=70, llcrnrlat=15,
urcrnrlon=140, urcrnrlat=55, lat_0=15, lon_0=95, resolution='l')
简单的把223.5.5.5 入图
loc = read.get('223.5.5.5')['location']
loc
{'latitude': 30.2936, 'longitude': 120.1614, 'time_zone': 'Asia/Shanghai'}
x, y = map(loc.get('longitude'), loc.get('latitude'))
map.drawcoastlines()
map.drawcountries()
map.fillcontinents(color='pink')
map.drawmapboundary()
map.plot(x, y, 'bo', markersize=4)
[<matplotlib.lines.Line2D at 0x7f0a7604d7f0>]
1.csv download from vpngate list
proxychains wget -O 1.csv http://www.vpngate.net/api/iphone/
df = pd.read_csv('/home/doom/1.csv', skiprows=1)
df = df[pd.notnull(df['IP'])]
read.get('103.208.85.121')
map = Basemap()
map.drawcoastlines()
map.drawcountries()
map.fillcontinents(color='pink')
map.drawmapboundary()
for i in df['IP']:
try:
loc = read.get(i)['location']
x, y = map(loc.get('longitude'), loc.get('latitude'))
map.plot(x, y, 'bo', markersize=11)
except Exception as e:
print("%s: %s" % (i, e))
103.208.85.121: 'NoneType' object is not subscriptable
103.192.207.236: 'NoneType' object is not subscriptable
156.208.205.247: 'NoneType' object is not subscriptable
讲道理大陆也是有节点的