Json 使用google flights包解析来自google flights的数据请求
我正在与google flights api(qpx)进行交互。我正在使用以下链接并使用以下实验包为请求提供信息: 以下是我迄今为止为任何有兴趣复制我的结果的人提供的代码:Json 使用google flights包解析来自google flights的数据请求,json,r,google-qpx-express-api,Json,R,Google Qpx Express Api,我正在与google flights api(qpx)进行交互。我正在使用以下链接并使用以下实验包为请求提供信息: 以下是我迄今为止为任何有兴趣复制我的结果的人提供的代码: #call library and data------------------------------------------------------------------- library(googleflights) library(MUCflights) #to access airport codes data
#call library and data-------------------------------------------------------------------
library(googleflights)
library(MUCflights) #to access airport codes
data("airports")
#codes for countries i'm interested in------------------------------------------
code_list = airports
#later interface for updating codes
my_destinations = matrix(c("San Juan", "Amsterdam", "Berlin",
"San Diego", "Lima", "Cali", "Havana"))
my_home = matrix(c("LGA", "JFK"))
#loop extract
code_list = airports
code_bucket = NULL
for (i in my_destinations) {
print(i)
drop = code_list[code_list$City == i,c("City","IATA")]
drop = as.data.frame(drop)
print(drop)
code_bucket = rbind(code_bucket, drop)
code_bucket = as.data.frame(code_bucket)
}
#clean my code bucket---------------------------------------------------------------
code_bucket = na.omit(code_bucket)
code_bucket = code_bucket[code_bucket$IATA != "",]
code_bucket
#feed in codes into function---------------------------------------------------------
#each ping to QPX will combine NYC to x
#data i want
# pricing
# times
key = "(key is here)"
set_apikey(key)
result_flights = search(my_home[1], code_bucket[2,2], "2016-11-27", "2016-11-28")
我一直在查看包的详细信息以了解其功能,并注意到请求返回时是一个列表,而不是JSON,它似乎是用于“summary_segment”函数的应用程序,该函数对我不起作用。以下是我引用的函数的链接:
我想知道是否有人有任何运气或想法来解析返回的请求?结果列表很大,我在处理这些结构方面已经达到了知识的极限。如果您能帮我指出正确的方向,我们将不胜感激