【问题标题】:Geopy error and timeoutGeopy 错误和超时
【发布时间】:2016-04-13 13:14:52
【问题描述】:

我已经在 python 项目中使用 geopy 大约两个月了。我可能已经使用了 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"    

【问题讨论】:

    标签: python geopy


    【解决方案1】:

    我猜 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 作业时,我确实达到了限制。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 2015-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多