小编S.D*_*rah的帖子

下一页令牌 R Google Places API

我正在尝试从 R 中的 Google Places API 获取餐厅详细信息。我可以成功获取 Google 提供的 20 个结果,但是我意识到,当它返回 a 时next_page_token,这意味着还有其他结果(这是合乎逻辑的,因为有超过我正在搜索的位置 50 公里半径范围内有 20 家餐厅)。但是,当我使用next_page_token它时,它会返回NULL。这是我的代码:

install.packages("googleway")
library(googleway)

key <- 'my key'

df_places <- google_places(search_string = "restaurant", 
                       location = c(-33, 151),
                       page_token = "next_page_token",
                       radius = 50000,
                       key = key)
df_places$results$name
df_places$results$rating
df_places$results$formatted_address
df_places$results$geometry$location
Run Code Online (Sandbox Code Playgroud)

这是它返回的内容,没有next_page_token:

 [1] "Gennaro's Italian Restaurant"                   
 [2] "Mount Broke Wines & Restaurant"                 
 [3] "Oak Dairy Bar"                                  
 [4] "Bimbadgen"                                      
 [5] "Subway Restaurant"                              
 [6] "Muse Restaurant"                                
 [7] "Ocean Restaurant"                               
Run Code Online (Sandbox Code Playgroud)

ETC... …

api null r google-api googleway

5
推荐指数
1
解决办法
1129
查看次数

标签 统计

api ×1

google-api ×1

googleway ×1

null ×1

r ×1