draft/getNike.R

getNike <- function(){
  URL <- 'http://www.nike.com/tw/zh_tw/sl/find-a-store?display_country=TW'
  res <- GET(URL, user_agent("mozilla/5.0"))
  res2 <- htmlParse(content(res, "text", encoding = "utf8"),encoding = "utf8")
  
  
  store_nm=xpathSApply(res2, '//*[@id="台灣"]/ul/li/a/div[1]', xmlValue)
  addr=xpathSApply(res2, '//*[@id="台灣"]/ul/li/a/div[2]', xmlValue)
  addr <- str_replace_all(addr, '(\r|\n| |\t)+', '')
  
  FINISH= data.frame(brand_nm='Nike',store_nm=store_nm,addr=addr, data_dt=gsub('-','',Sys.Date()) ,stringsAsFactors=FALSE )
  
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.