How to pass a variable in url in fromJSON command

2019-07-30 23:01发布

I am trying to pass a variable in the url and flatten using jsonlite, but i am not able to pass variable pages using the loop. How do i loop using FromJSON?

pages<- list()
for(i in 1:20) {
mydata <- fromJSON("https:www.example.com/page="+i+"&access_token=xyz", flatten = TRUE) 
}
filings <-rbind.pages(pages)

1条回答
太酷不给撩
2楼-- · 2019-07-30 23:30

What about this?

pages<- list()
for(i in 1:20) {
  mydata <- fromJSON(paste("https:www.example.com/page=", i, "&access_token=xyz", sep = "+"), flatten = TRUE)
}
filings <-rbind.pages(pages)
查看更多
登录 后发表回答