1

I am using the Googleway package, specifically, the google_places() function to extract store data. I understood that each google_places() call produce 20 data and I can access a total of 60 with next page token. My problem is, I was able to access the second 20 data points, but not the last 20 as it prompts a error message.

key <- 'insert own api key'
loc <- c(33.685494, -117.812070)
df <- google_places(place_type = "store",location = loc, radius = 1500, key = key)
df_next <- google_places(place_type = "store",location = loc, radius = 1500, key = key, page_token = df$next_page_token)

Until this point everything works and I was able to get 40 stores.

df_next_two <- google_places(location = loc, radius = 1500, key = key, page_token = df_next$next_page_token)

This creates an error:

Error: lexical error: invalid char in json text.
                                   https://maps.googleapis.com/map
                 (right here) ------^

Is there a way to get around this? Thanks.

Marco
  • 2,368
  • 6
  • 22
  • 48
Alex
  • 11
  • 1
  • 1
    Your code works fine for me. Maybe you're out of api uses for the day? Also, your last search doesn't have the place_type = "store" parameter, but it wasn't a problem for me. – Luis May 09 '18 at 20:03
  • That's odd. I tried using another api key but it still prompted the same error message when entering the last code. – Alex May 09 '18 at 20:33
  • See [this related issue](https://github.com/SymbolixAU/googleway/issues/93#issuecomment-385562285) - it may be you need to install the development version where I've had to make a couple of changes to resolve similar errors for some people – SymbolixAU May 09 '18 at 21:59

1 Answers1

0

As Luis said, the code works in principle:

loc <- c(33.685494, -117.812070)
df <- google_places(place_type = "store",location = loc, radius = 1500, key = key)
df_next <- google_places(place_type = "store",location = loc, radius = 1500, key = key, page_token = df$next_page_token)
df_next_two <- google_places(location = loc, radius = 1500, key = key, page_token = df_next$next_page_token)

cbind(df$results$name, df_next$results$name, df_next_two$results$name)

      [,1]                                [,2]                           [,3]                                             
 [1,] "Marshalls"                         "European Wax Center"          "Cyndi Allcott Skin Therapy and Permanent Makeup"
 [2,] "Target"                            "Shell"                        "Indus Connections"                              
 [3,] "Peet's Coffee"                     "Optical Training Institute"   "Nexgen Pharma"                                  
 [4,] "CVS Pharmacy"                      "K.K. Termite, Inc."           "Woodbridge Optometry"                           
 [5,] "Pest Control Service"              "Heritage Signs & Graphics"    "Vacuum Depot Irvine"                            
 [6,] "T-Mobile"                          "Target Mobile"                "OC Succulents"                                  
 [7,] "FedEx Office Print & Ship Center"  "Starbucks"                    "Molly's Music - The Inside Voice"               
 [8,] "Mimi's Cafe"                       "Love and Lace Bridal Salon"   "The Poppy Studio"                               
 [9,] "Sprouts Farmers Market"            "Pantheon Packaging"           "United Sustainable Surfacing of America"        
[10,] "Barranca Optometry"                "The UPS Store"                "Yogurt Passion"                                 
[11,] "Layer Cake Bakery (LCB)"           "Crossroads Trading"           "Dancing Keys Music Studio"                      
[12,] "Starbucks"                         "Ortho Mattress"               "Sonus Hearing Care Professionals"               
[13,] "Extra Space Storage"               "7-Eleven"                     "Conroy's Flowers"                               
[14,] "GNC"                               "Aztech Construction Inc"      "Cello Lessons with Feliks Volozhanin"           
[15,] "Panera Bread"                      "Pars Pharmacy"                "Pearle Vision"                                  
[16,] "Amy's Hallmark Shop"               "Global RX Pharmacy"           "Target Grocery"                                 
[17,] "Noresco"                           "Electronic Eye Security Inc." "Pedego Electric Bikes Irvine"                   
[18,] "Daniel C Kline MD Inc"             "Public Storage"               "Komal Kumar"                                    
[19,] "Mohsen S. Alinaghian, Optometrist" "Extra Space Storage"          "AT&T Store"                                     
[20,] "Circle K"                          "Planet Beauty"                "Maureen Pietryga"   
Marco
  • 2,368
  • 6
  • 22
  • 48