draft/getFuji.R

getFuji <- function(){
  url       <- 'http://www.efuji.com.tw/Themes/NopShopDIY/Scripts/_locations.json'
  htmldoc1  <- content(GET(url, encoding='utf8'), as='text', encoding='utf8')
  info1     <- str_replace_all(htmldoc1,'(\r)|(\n)|(\t)','   ') 
  info2     <- str_split(info1,"   ")[[1]]
  
  store_nm1 <- na.exclude(str_extract(info2,'title.+'))
  store_nm2 <- str_replace(str_replace(store_nm1,'title\": \"',''),'\",','')
  
  addr1     <- na.exclude(str_extract(info2,'address.+'))
  addr2     <- str_replace(str_replace(addr1,'address\": \"',''),'\",','')
  
  tel1      <- na.exclude(str_extract(info2,'tel.+'))
  tel2      <- str_replace(str_replace(tel1,'tel\": \"',''),'\",','')
  
  data1     <- data.frame('FUJI',store_nm2,addr2,tel2)
  
  names(data1) <- c('brand_nm','store_nm', 'addr', 'tel_no')
  return(data1)
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.