想用R抓取网页数据,到pagetree为止都没有问题,但是取数据却报错,Xpath是通过Chrome Copy获得,非常着急,望各位大大帮助!
require(XML)
require(RCurl)
webpage<- getURL('http://www.howbuy.com/fund/001066/index.htm?source=aladdin&HTAG=0.0040010007900000#jjcb')
webpage <- readLines(tc <- textConnection(webpage)); close(tc)
pagetree <- htmlTreeParse(webpage, error=function(...){},useInternalNodes = TRUE)
tablehead <- xpathSApply(pagetree, "//*[@id="nTab2_6"]/div/div/h4", xmlValue)
Error: unexpected symbol in "tablehead <- xpathApply(pagetree, "//*[@id="nTab2_6"