draft/getTeaMax.R

getTeaMax <- function(){
  #取得資訊
  url<-'http://tea-max.com/stores.html'
  res <- GET(url)
  res <- content(res,'text', encoding = 'utf8')
  html <- htmlParse(res, encoding = "utf8")
  tables <- readHTMLTable(html)
  
  result <- list()
  
  for (i in 6:19){
    tables1 <-tables[i][[1]]
    store_nm<-tables1[,1]
    tel_no  <-tables1[,2]
    addr    <-tables1[,3]
    result[[i]]<-data.frame(brand_nm='喫茶享樂',store_nm, tel_no, addr, stringsAsFactors = FALSE)
  }
  
  data_fin  <- do.call(rbind, result)
  data_fin  <- data_fin[!str_detect(data_fin$store_nm, '無'),]
  return(data_fin)
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.