下一页令牌不会与结果一起打印

时间:2021-05-25 13:06:33

标签: python google-places-api

我正在编写一个简单的脚本来获取有关地点的信息。我遵循了几个教程,这就是我想出的。

下面的代码返回了我需要的结果,但没有给我超过 20 个结果,places API 允许最多 60 个结果。

由于某种原因,page_token 参数未被确认并被忽略。

有人能帮我解决这个问题吗??

API_key = 'MY API KEY(left out on purpose)'

gmaps = googlemaps.Client(key= API_key)

place_result_list = []

places_result = gmaps.places_nearby(location= "40.853137,-74.104602",radius =5000,open_now = False, type = "restaurant")


time.sleep(3)


places_result  = gmaps.places_nearby(page_token = places_result['next_page_token'])


for place in places_result['results']:
    my_place_id = place['place_id']
    my_fields = ['name','formatted_phone_number','website','formatted_address','geometry/location/lat','geometry/location/lng']
    places_details = gmaps.place(place_id=my_place_id, fields=my_fields)
    print(places_details['result'])

我做错了什么?

0 个答案:

没有答案