Geopy错误和超时

时间:2016-04-13 13:14:53

标签: python geopy

我一直在使用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"    

1 个答案:

答案 0 :(得分: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"