开发者

Python API to know the location

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜