Is there a way to get the computer\'s physical position using Python, preferably without an API, or with a free API? I\'ve searched around a bit, and the only free API I\'ve
If you know the public IP of the device then you can do so by using freegeip. Below is the Python 3.4.2 code for getting location and time zone.
>>> import requests
>>> ip = '141.70.111.66'
>>> url = 'http://freegeoip.net/json/'+ip
>>> r = requests.get(url)
>>> js = r.json()
>>> js['country_code']
'DE'
>>> js['country_name']
'Germany'
>>> js['time_zone']
'Europe/Berlin'
>>> js['city']
'Stuttgart'
>>> js.items()
dict_items([('latitude', 48.7667), ('ip', '141.70.111.66'), ('region_code', 'BW'), ('country_code', 'DE'), ('city', 'Stuttgart'), ('zip_code', '70173'), ('country_name', 'Germany'), ('longitude', 9.1833), ('region_name', 'Baden-Württemberg Region'), ('time_zone', 'Europe/Berlin'), ('metro_code', 0)])