Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access current location of any user using python [closed]

Is there anyway that I can get the location of my device through python. Currently I am having to use selenium and open up a browser, use a location service website and setting the result of that to variables for lat/long.

But is there an easier way to do this?

UPDATE: I am using a 3G dongle on my RaspberryPi, so looking for a way to get the specific lat/long of it - I can successfully do this through web service, just wondering if there is a quicker way built into python for these requests?

like image 282
Stacker-flow Avatar asked Jul 23 '14 09:07

Stacker-flow


People also ask

How do I find current user location?

In order to get the last location of the user, make use of the Java public class FusedLocationProviderClient. It is actually a location service that combines GPS location and network location to achieve a balance between battery consumption and accuracy.

How extract IP address location?

Just send HTTP GET request to https://api.ipgeolocationapi.com with different parameters and get the JSON result. For example, the following HTTP GET request will give you a location of the specified IP address. The following request returns the country information specified by the ISO country code.


2 Answers

or, as simple as this

import geocoder g = geocoder.ip('me') print(g.latlng) 
like image 151
Apollo_LFB Avatar answered Sep 30 '22 09:09

Apollo_LFB


Others have mentioned a few services, but another one to consider is my own, https://ipinfo.io, which'll give you latitude, longitude and a bunch of other information:

Usage for Bash:

$ curl ipinfo.io {   "ip": "24.6.61.239",   "hostname": "c-24-6-61-239.hsd1.ca.comcast.net",   "city": "Mountain View",   "region": "California",   "country": "US",   "loc": "37.3845,-122.0881",   "org": "AS7922 Comcast Cable Communications, LLC",   "postal": "94040" } 

If you only want the coordinate data you can get just that by requesting /loc:

$ curl ipinfo.io/loc 37.3845,-122.0881 

See https://ipinfo.io/developers for more details.

like image 40
Ben Dowling Avatar answered Sep 30 '22 08:09

Ben Dowling