【发布时间】: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