views:

370

answers:

2

Hi, I'm tying to get a certain Python script (although I guess it isn't really the language that's going to matter here) to find out the current geographic location of the machine running it. As you might have guessed, it's a little script that reports my laptop's location when it boots and stuff :)
Is there any free web service or API to do this? I was pretty impressed by Google Maps' ability to pinpoint my house (it was off by only ~5 meters!).

+3  A: 

I came across this Python script http://netsekure.org/wp-content/uploads/ip2loc.py which might be something similar to what you are looking for.

Himanshu
The script you cited only finds my ISP's address a few counties away, rather than mine, but that's probably as close as you can expect to get with public data. It looks like a nice script. Relies on having an Internet connection, of course, but so does sending the email, so this answer looks like a good one! +1
Brandon Craig Rhodes
+1  A: 

You may be able to use Google's GeoLocation API (API docs here). From the docs:

"Communication is done over HTTP, with Gears making the request using HTTP POST. Both request and response are formatted as JSON, and the content type of both is application/json."

The python standard library json module can be found here.

But what's the IP or DNS of a location provider to target with that HTTP POST? (Besides the issue of locating cellphone towers, wifi providers, etc, to help narrow things down wrt "just the IP"...).
Alex Martelli
Yeah, where to send such a request?
Etienne Perot