Skip to content

Instantly share code, notes, and snippets.

@kentatogashi
Last active June 14, 2018 01:41
Show Gist options
  • Save kentatogashi/9ab64954fb859121fb625b3d317bede3 to your computer and use it in GitHub Desktop.
Save kentatogashi/9ab64954fb859121fb625b3d317bede3 to your computer and use it in GitHub Desktop.
Python3で、GeoIPを使うための備忘録
  • ライブラリをインストール $ sudo apt install libgeoip1 libgeoip-dev geoip-bin
  • Pythonのライブラリをインストール $ pip install GeoIP
  • 実行例
In [1]: import GeoIP

In [2]: gi = GeoIP.open('/usr/share/GeoIP/GeoIP.dat', GeoIP.GEOIP_MEMORY_CACHE)

In [3]: gi.country_code_by_name('google.com')
Out[3]: 'US'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment