draft/getOsim.R

getOsim <- function(){
  
  URL <- 'http://www.osim.com/uinfinity/mob/tw/store-locator.html'
  res <- GET(URL, encoding='utf8')
  res2 <- htmlParse(content(res, "text", encoding = "utf8"), encoding = "utf8")
  store_nm <- cssApply(res2,'ul > li > h4',cssCharacter)
  
  result <- cssApply(res2,'ul > li > p ',cssCharacter)
  result <- unlist(strsplit(result,'\n'))
  result2 <- str_replace_all(result,'[:space:]','')
  result2 <- result2[nchar(result2)>0]
  result3 <- matrix(result2, ncol = 2, byrow = TRUE)
  
  addr <- result3[,1]
  tel_no <- result3[,2]
  tel_no <- str_replace(tel_no,'電話:','')
  osim = data.frame(brand_nm='OSIM',store_nm=store_nm,addr=addr,tel_no=tel_no, stringsAsFactors=FALSE)  
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.