Python 下一页标记GooglePlaces

Python 下一页标记GooglePlaces,python,google-maps,google-places-api,google-places,Python,Google Maps,Google Places Api,Google Places,我正试图转到下一页,但我的错误请求被拒绝我管理了一个代码,我只得到了20条记录我还使用睡眠来阻止请求,但没有任何机会你能帮我吗 from googleplaces import GooglePlaces, types, lang from unidecode import unidecode import json import time import requests YOUR_API_KEY = 'AIzaSyAZo0lBWrvWa_aOnt1goJl5Z1imYg0tv-k' goog

我正试图转到下一页,但我的错误请求被拒绝我管理了一个代码,我只得到了20条记录我还使用睡眠来阻止请求,但没有任何机会你能帮我吗

from googleplaces import GooglePlaces, types, lang
from unidecode import unidecode 
import json
import time
import requests

YOUR_API_KEY = 'AIzaSyAZo0lBWrvWa_aOnt1goJl5Z1imYg0tv-k'
google_places = GooglePlaces(YOUR_API_KEY)
query_result = google_places.nearby_search(
        lat_lng={'lat' : 46.1667, 'lng' : -1.15}, 
        radius=5000,
        types=[types.TYPE_RESTAURANT] or [types.TYPE_CAFE] or [type.TYPE_BAR] or [type.TYPE_CASINO])
time.sleep(10)  


for place in query_result.places:
         place.get_details()
         print place.place_id

         print unidecode(place.name)

if query_result.has_next_page_token:
    query_result_next_page = google_places.nearby_search(
                pagetoken=query_result.next_page_token)
    for pl in query_result.places:
        pl.get_details()
        print pl.place_id
             #places.append(place.place_id)
        print unidecode(pl.name)

使用pagetoken,您需要包含来自父页面查询的其他参数。另外,为了获得下一页的结果,您需要迭代新的查询

from googleplaces import GooglePlaces, types, lang
from unidecode import unidecode 
import json
import time
import requests

YOUR_API_KEY = 'AIzaSyAZo0lBWrvWa_aOnt1goJl5Z1imYg0tv-k'
google_places = GooglePlaces(YOUR_API_KEY)
query_result = google_places.nearby_search(
        lat_lng={'lat' : 46.1667, 'lng' : -1.15}, 
        radius=5000,
        types=[types.TYPE_RESTAURANT] or [types.TYPE_CAFE] or [type.TYPE_BAR] or 
              [type.TYPE_CASINO])
time.sleep(10)  


for place in query_result.places:
         place.get_details()
         print place.place_id
         print unidecode(place.name)

if query_result.has_next_page_token:
    query_result_next_page = google_places.nearby_search(
        lat_lng={'lat' : 46.1667, 'lng' : -1.15}, 
        radius=5000,
        types=[types.TYPE_RESTAURANT] or [types.TYPE_CAFE] or [type.TYPE_BAR] or 
              [type.TYPE_CASINO], pagetoken=query_result.next_page_token)
    for pl in query_result_next_page.places:
        pl.get_details()
        print pl.place_id
        #places.append(place.place_id)
        print unidecode(pl.name)

我只看到下一页,但我不能看到所有的页面如果你使用标准的GooglePlaceAPI,一次调用最多可以得到60个位置。以上代码将为您提供40个位置。要获得另一个20,您需要在query\u result\u next\u页面块下编写类似的子代码。要了解更多信息,您必须选择高级计划