library(RCurl)
library(bitops)
library(jsonlite)
url<-"http://www.***.com/content/list"
x=1
for( x in 1:55643){
web[[x]]<-fromJSON(postForm(url,page=x,category=-1,.opts=curlOptions(url=url,ssl.verifyhost=FALSE,ssl.verifypeer=FALSE)))
}
title<-as.character(sapply(web,function(x) x$data$contentBeans$title))
category<-as.character(sapply(web,function(x) x$data$contentBeans$category))
time<-as.character(sapply(web,function(x) x$data$contentBeans$time))
name<-as.character(sapply(web,function(x) x$data$contentBeans$name))
avatar<-as.character(sapply(web,function(x) x$data$contentBeans$avatar))
readCount<-as.character(sapply(web,function(x) x$data$contentBeans$readCount))
get_data<-data.frame(title,name,category,time,readCount,avatar)
write.csv(get_data,"~/Desktop/data2.csv")
一段R语言抓取某网站JSON数据的代码。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20707698/viewspace-2213858/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/20707698/viewspace-2213858/