knitr::opts_chunk$set(echo=TRUE)
library(XML)
library(RCurl)
strurl<-‘https://movie.douban.com/top250’
movie<-RCurl::getURL(strurl)
movie<-htmlParse(movie)
nodes<-getNodeSet(movie,”//div[@class=’info’]//a//span[1]”)
moviename<-sapply(nodes,xmlValue)
moviename[1:10]
[1] “肖申克的救赎” “霸王别姬” “阿甘正传” “这个杀手不太冷”
[5] “美丽人生” “泰坦尼克号” “千与千寻” “辛德勒的名单”
[9] “盗梦空间” “忠犬八公的故事”