1

I try to capture the info in a list on r when I'm using page_token in google_places

In general the short code is functional, but I can see in google.maps 65 results, and my code just return me 60 results.

key_word = 'McDonalds Bogota'
res <- google_places(search_string = key_word)
  info <- list(res)
  while (res$status == 'OK') {
    Sys.sleep(1.5)
    res <- google_places(search_string = '',
                         page_token = res$next_page_token)
    info <- c(info,list(res))
  }

I obtain a list with complete information in info[[1]], info[[2]] and info[[3]], but when I see info[[4]] I get status INVALID_REQUEST, so I want to see the final 5 observations in info[[4]] but I could not to do this

1 Answers1

0

info[[3]] does not have a $next_page_token since the number of results caps at 60. So the following loop for info[[4]] will not have a valid token to request more results.

next_page_token contains a token that can be used to return up to 20 additional results. A next_page_token will not be returned if there are no additional results to display. The maximum number of results that can be returned is 60.

https://developers.google.com/places/web-service/search

Ben
  • 28,684
  • 5
  • 23
  • 45