File: city.py

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

from __future__ import print_function

import GeoIP

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

gir = gi.record_by_name("www.google.com")
#gir = gi.record_by_addr("24.24.24.24")

if gir is not None:
    print(gir['country_code'])
    print(gir['country_code3'])
    print(gir['country_name'])
    print(gir['city'])
    print(gir['region'])
    print(gir['region_name'])
    print(gir['postal_code'])
    print(gir['latitude'])
    print(gir['longitude'])
    print(gir['area_code'])
    print(gir['time_zone'])
    print(gir['metro_code'])
    print(str(gir))