Skip to content

Instantly share code, notes, and snippets.

@vxf
Created October 21, 2013 01:16
Show Gist options
  • Save vxf/7077357 to your computer and use it in GitHub Desktop.
Save vxf/7077357 to your computer and use it in GitHub Desktop.
python script to quickly geolocate ip addresses en masse with libgeoip ( cat ips.txt | python ip2geo.py )
import os, GeoIP, fileinput
geo = GeoIP.new(GeoIP.GEOIP_MEMORY_CACHE)
for line in fileinput.input():
try:
print(geo.country_code_by_addr(line.strip()))
except IOError:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment