r语言 - google_places() Googleway 包中的下一页令牌



我正在使用Googleway包,特别是google_places()函数来提取存储数据。我知道每个google_places()调用都会产生 20 个数据,我可以使用下一页令牌访问总共 60 个数据。我的问题是,我能够访问第二个 20 个数据点,但无法访问最后 20 个数据点,因为它会提示错误消息。

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)

到目前为止,一切正常,我能够获得40家商店。

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

这将创建一个错误:

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

有没有办法解决这个问题?谢谢。

正如Luis所说,代码原则上有效:

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"   

相关内容

  • 没有找到相关文章

最新更新