File: region.py

package info (click to toggle)
python-geoip 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 352 kB
  • sloc: ansic: 753; python: 248; makefile: 4
file content (19 lines) | stat: -rw-r--r-- 489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python

from __future__ import print_function

import GeoIP

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

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

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