Geopy错误和超时

3
我在Python项目中使用geopy已经有大约两个月的时间了。我可能只使用了100次代码,每次只获取一个返回结果。所以我不认为我会滥用它。
昨天我遇到了超时错误,今天我又遇到了以下错误:
geopy.exc.GeocoderInsufficientPrivileges: HTTP Error 403: Forbidden.
我该如何获得"足够的特权"? 有人知道我该如何发送电子邮件或支付才能使其正常工作吗?
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个回答

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"    

我在使用GoogleV3时遇到了随机超时的情况,据说每天最多可以进行2500次查询。有一天我没有正确设置cron作业,就达到了限制。 - Michael Mathews

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接