Я делаю запрос от API Google Адресов с запросом "Отели в Бразилии" со следующим кодом:
# url variable store url
url = "https://maps.googleapis.com/maps/api/place/textsearch/json?"
# The text string on which to search
query = input('Search query: ')
# get method of requests module
# return response object
r = requests.get(url + 'query=' + query +
'&key=' + api_key +
'&maxResults=1000')
# json method of response object convert
x = r.json()
# store the value of result key in variable y
y = x['results']
#Getting information from other pages with "next_page_token" param
places=[]
params = {
'query': query,
'key' : api_key,
'maxResults': '1000'
}
while "next_page_token" in x:
params['pageToken'] = x['next_page_token'],
res = requests.get(url, params = params)
z = json.loads(res.content)
places.extend(z['results'])
print(places)
Но возвращение результатов занимает слишком много времени (более 1 дня ). Поэтому я остановил выполнение, и когда я распечатал его, у меня появилось много повторных имен, например, я получил 16 тыс. Мест, но только 26 уникальных мест.
Можно ли вернуть уникальные значения из API Google Адресов?