开发者

Python API to know the location

开发者 https://www.devze.com 2023-01-25 06:41 出处:网络
Is there an Python API from whi开发者_开发技巧ch if weinput the ipadress, will we be able to know the location and place of the access Take a look at the MaxMind python APIGeoDjango looks like it will

Is there an Python API from whi开发者_开发技巧ch if we input the ipadress, will we be able to know the location and place of the access


Take a look at the MaxMind python API


GeoDjango looks like it will suit your needs. I'm not sure exactly how you would want to direct users, but using the GeoIP API, you can do something like:

from django.contrib.gis.utils import GeoIP

g = GeoIP()

ip = request.META.get('REMOTE_ADDR', None)

if ip:

    city = g.city(ip)['city']

print "ip:",ip," city:",city

The Docs explain things in great detail (http://docs.djangoproject.com/en/dev/ref/contrib/gis/); I would take a moment to read through them thoroughly

0

精彩评论

暂无评论...
验证码 换一张
取 消