draft/getRoots.R

getRoots <- function(){
  url<-'http://www.roots.com.tw/branch?branch_region=%25E5%2585%25A8%25E9%2583%25A8'
  res <- GET(url)
  res <- content(res,'text', encoding = 'utf8')
  html <- htmlParse(res, encoding = "utf8")
  
  data<- cssApply(html,"td:nth-child(1) > table  > tr:nth-child(2) > td", cssCharacter) 
  data  <- matrix(data, ncol=4, byrow=TRUE)
  
  store_nm<-str_replace_all(data[,1], '\r|\n|\t|[:space:]','')
  tel_no   <-data[,3]
  addr     <-data[,2]
  
  result<-data.frame(brand_nm='ROOTS',store_nm, tel_no, addr, stringsAsFactors = FALSE)
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.