library(httr); library(XML); library(tmcn); req <- GET("http://www.twse.com.tw/ch/trading/fund/TWT38U/TWT38U.php",encoding='utf8') req <- content(req,'text', encoding = 'utf8') req <- htmlParse(req, encoding = 'utf8') dd <- xpathSApply(req, '//*[@id="main-content"]/table/tbody/tr/td', xmlValue) tablehead<-iconv(dd,"UTF-8","CP950") table <- matrix(tablehead, ncol = 6, byrow = T) write.csv(table,file = "C:\\TWSE.csv" ,row.names = FALSE)