0

有没有办法从 Python 脚本中获取计算机地理位置(如谷歌地图“我的位置”)?计算机将始终连接到 Internet。

4

2 回答 2

3
>>> import re,requests
>>> raw = requests.get('http://www.geoiptool.com/').text
>>> latlon = re.search("GPoint\(([^)]+)\)",raw).groups(0)
>>> lat,lon = map(float,latlon[0].split(","))
>>> print "Latitude:%s   Longitude:%s"%(lat,lon)
Latitude:-117.2455   Longitude:46.7322

几个警告...

  1. 这可能不是最好的方法,不应该一遍又一遍地做,否则你可能会惹恼网站所有者

  2. 这使用 IP 查找,因此它可能不如 GPS/wifi 坐标

于 2013-07-17T18:51:00.197 回答
0

Google 地图许可不允许在地图对象之外使用地理编码服务 API。看看这个问题https://gis.stackexchange.com/questions/18871/is-there-an-open-source-geocoding-tool-which-can-be-used-commercially。希望能帮助到你。

于 2013-07-17T16:06:33.150 回答