在 URL 中使用页面令牌,您可以获得所有结果。
要求:
你可以试试下面的代码:
import requests
import json
final_data = []
location='24.4165267,75.833981'
radius='2000'
types='restaurant'
url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%s&radius=%s&types=%s&key=api key" % (location,radius,types)
while True:
response = requests.request("POST", URL)
response = json.loads(response.text)
results = response['results']
for result in results:
final_data.append(data)
if 'next_page_token' not in response:
break
else:
next_page_token = response['next_page_token']
next_page_token = '&pagetoken=%s' % str(next_page_token)
url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%s&radius=%s&types=%s&key=api key%s" % (location,radius,types,next_page_token)
print(final_data)