请问错误在哪里?怎么从R语言导出数据?

install.packages('XML')
install.packages('httr')
library(XML)
library(httr)
urls<-'http://www.filmsite.org/filmgenres.html'
parsed<-htmlParse(urls)
tab<-readHTMLTable(parsed)
tab[3]

url_1<-'http://movie.douban.com/top250?start='
page<-seq(0,225,25)
url_new<-paste(url_1,page,sep='')
lapply(url_new,function(x) readHTMLTable(htmlParse(x)))

movies<-lapply(url_new,function(x) htmlParse(x))
lapply(movies,function(x) xpathSApply(x,"//span[@class='title']",xmlValue))
write.table(url_2,'E:/movies.csv',sep=',',col.names=NA)

#url_2都没有定义。
#想保存

lapply(movies,function(x) xpathSApply(x,"//span[@class='title']",xmlValue))

#的结果,得先用值存结果

mov <- lapply(movies,function(x) xpathSApply(x,"//span[@class='title']",xmlValue))

#mov是list,得转换一下,结果付给url_2

url_2 <- unlist(mov)

#然后保存
write.table(url_2,'E:/movies.csv',sep=',',col.names=NA)

追问

已经阵亡。。。

已经阵亡。。。

温馨提示:答案为网友推荐,仅供参考
相似回答