Page 1 of 1

best way to use an IP address to find what state....

Posted: Sat May 14, 2011 8:58 pm
by Isaac
...someone's in.

Using python cgi on my server, I can log a user's the IP address when they come to my site, along with most other activity. So I would like my new comment box to take this info and post what State or province the comment came from, next to the name of the person and time stamp.

I wondering if there's a common application on the server I can use, rather than have python use a different website. I think cpanel does this to some degree, so I think my CGI app could do this too.

Re: best way to use an IP address to find what state....

Posted: Sun May 15, 2011 12:00 am
by Jeff250
There are tables for IP address -> country lookups (e.g. D2x XL comes with one as a *.csv file). I've never seen them for IP address -> state/province, but maybe they exist. They'd probably be more temperamental though. Are you expecting all of your visitors to even be from the U.S. or Canada?

This is probably a bad idea though in general due to proxies. All AOL traffic used to be (and perhaps still is) proxied through Virginia. Someone might be using Tor, which means they might show as a different state (or country) every time they post. Maybe you should just let users optionally say where they are from? They might not even like being forcibly identified by state.

Re: best way to use an IP address to find what state....

Posted: Sun May 15, 2011 12:45 pm
by Isaac
Yeah. I guess it's not worth the effort. But maybe a section that lets users opt into stating what place they're from would be fine.

Thanks.

Re: best way to use an IP address to find what state....

Posted: Fri Jun 17, 2011 1:11 pm
by Isaac
Putting this here in case I forget...

http://ipinfodb.com/ip_location_api.php

Re: best way to use an IP address to find what state....

Posted: Mon Sep 26, 2011 5:26 am
by R e v
http://www.maxmind.com/app/geolitecity

Free monthly city-level data set.