Sat Jul 28, 2012 4:27 pm
https://github.com/appliedsec/pygeoip
import GeoIP
## creating an object
myGeoIP = GeoIP.new(GeoIP.GEOIP_STANDARD)
print myGeoIP.country_code_by_addr("193.45.25.158")
print myGeoIP.country_code_by_name("codemiles.com")
## Using GeoIP Memory Cache
myGeoIP = GeoIP.new(GeoIP.GEOIP_MEMORY_CACHE | GeoIP.GEOIP_CHECK_CACHE)
print geo.country_code_by_addr("173.15.27.167")
print geo.country_code_by_name("codemiles.com")
## using the City database
myGeoIP=GeoIP.open("/usr/local/share/GeoIP/GeoIPCity.dat",GeoIP.GEOIP_STANDARD)
print "Using GeoIP City database"
geoRecord = geo.record_by_addr("173.15.27.167")
if geoRecord!= None:
print geoRecord ['country_code']
print geoRecord ['country_name']
print geoRecord ['time_zone']
print geoRecord ['city']
print geoRecord ['region']
print geoRecord ['region_name']
print geoRecord ['postal_code']
print geoRecord ['latitude']
print geoRecord ['longitude']
print geoRecord ['area_code']
myGeoIP = GeoIP.new(GeoIP.GEOIP_MEMORY_CACHE | GeoIP.GEOIP_CHECK_CACHE)
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.