【问题标题】:What can I do to settle this error "raise googlemaps.exceptions.Timeout()" in working with Google places api?在使用 Google Places api 时,我可以做些什么来解决这个错误“raise googlemaps.exceptions.Timeout()”?
【发布时间】:2019-10-30 17:30:46
【问题描述】:

我必须得到一些地方的一些细节。我在 Python 中编写了一个代码来使用 Google Places API 自动执行此操作。我使用了两个查询来自动化这个功能。它们是“附近搜索”“地点详情”。执行程序后,我可以获得一些地方的详细信息。但是,在执行程序时,发生了googlemaps.exceptions.Timeout 异常。我还没有启用计费。这是我的代码中的问题还是其他问题?开启计费后这个错误会解决吗?

gmaps = googlemaps.Client(key = API_Key)

def search_places(location, radius, type):
    places = gmaps.places_nearby(location = location, radius = radius, type = type)
    time.sleep(3)
    pprint.pprint(places)
    for place in places['results']:
        place_id = place['place_id']
        fields = ['name', 'formatted_address', 'formatted_phone_number', 'rating', 'website']
        place_details = gmaps.place(place_id = place_id, fields = fields)
        pprint.pprint(place_details)
        time.sleep(3)

search_places('40.712776,-74.005974', '20000', 'restaurant')

错误是:

raise googlemaps.exceptions.Timeout()

【问题讨论】:

    标签: python google-maps google-maps-api-3 google-places-api


    【解决方案1】:

    确实需要为 Places API 启用计费功能。查看Google's Billing documentation

    提醒:要使用 Places API,您必须包含一个 API 密钥 API 请求,并且您必须为每个项目启用结算功能

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-30
      • 2012-02-14
      • 2020-11-16
      • 2019-04-22
      • 2022-01-03
      • 1970-01-01
      相关资源
      最近更新 更多