File: test_region.py

package info (click to toggle)
python-geoip 1.2.1-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 108 kB
  • ctags: 43
  • sloc: ansic: 262; python: 45; makefile: 3
file content (15 lines) | stat: -rwxr-xr-x 367 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/python

import GeoIP

gi = GeoIP.open("/usr/local/share/GeoIP/GeoIPRegion.dat",GeoIP.GEOIP_STANDARD)

gir = gi.region_by_name("www.google.com")
if gir != None:
            print gir['country_code']
            print gir['region']

gir = gi.region_by_addr("24.24.24.24")
if gir != None:
            print gir['country_code']
            print gir['region']