3

我已经将 geopy 用于 python 项目大约两个月了。我可能已经使用了 100 次以下的代码,一次只得到一个回报。所以我不认为我在滥用它。

昨天我收到超时错误,今天我收到以下错误:

geopy.exc.GeocoderInsufficientPrivileges:HTTP 错误 403:禁止。

我怎样才能获得“足够的特权”?任何人都知道我如何通过电子邮件或付款来完成这项工作?

from geopy.geocoders import Nominatim
import csv

   def geopy(): 

       loc = raw_input("What location? ")
       geolocator = Nominatim()
       location = geolocator.geocode(loc, timeout=None) # timeout is the amount of time it will wait for return 
       if location != None:
           Address = location.address
           lat_long = location.latitude,location.longitude

      else:
           print "There is no geographic information to return for the word in input. \n"    
4

1 回答 1

2

我猜 Nominatim 已经停止工作,所以我使用了 GoogleV3。这会返回较少的地址信息,但它可能仍然有效。

from geopy.geocoders import GoogleV3
def geopy(): 

    loc = raw_input("What location? ")
    geolocator =  GoogleV3()
    location = geolocator.geocode(loc)
    if location != None:
        Address = location.address
        lat_long = location.latitude,location.longitude
        print Address, lat_long

    else:
        print "There is no geographic information to return for the word in input. \n"    
于 2016-04-13T17:38:06.647 回答