GeoIP with google app engine and python

2020-07-18 09:05发布

I am trying to add the following feature to my application.

Sequence of actions:

  1. User goes to the web application

  2. Web application detects the country and city based on the users IP address

  3. Web application automatically selects users country and city and shows it to the user.

I tried searching for this and even asked a question in the google app engine google group, but i couldn't find a reliable way to get this done in google app engine.
Does anyone have any points where i can get started on this?

2条回答
在下西门庆
2楼-- · 2020-07-18 09:15

I would use the Simplegeo API. There's a very fast call to do just this. https://simplegeo.com/docs/api-endpoints/simplegeo-places

查看更多
SAY GOODBYE
3楼-- · 2020-07-18 09:28

If you need to do this server-side then you will need to get hold of one of the databases that map IP addresses to countries/cities. These databases go out of date requenquently and so are usually commercial. Maxmind have various licences for their database including some free ones I believe.

However, if you could move the check on to the client-side, in the browser you could make an ajax call to Maxmind's free JSONP API to fetch the estimated location of your user, and then let your application handle the decisions using javascript.

查看更多
登录 后发表回答