draft/getJohnnieWalker.R

getJohnnieWalker <- function(){
  
  res <- GET("http://www.jwtwglcampaign.com/green.php")
  res <- htmlParse(content(res,'text', encoding = 'utf8'), encoding = 'utf8')
  #--------------------------------------------------------------------------------------
  store_nm=xpathSApply(res, '//html/body/div/div/div[2]/div[1]/div[2]/div/div/div[1]/text()[1]', xmlValue)
  store_nm <- str_replace_all(store_nm, '(\r|\n| )+', '')
  addr=xpathSApply(res, '//html/body/div/div/div[2]/div[1]/div[2]/div/div/div[1]/text()[2]', xmlValue)
  addr <- str_replace_all(addr, '(\r|\n| )+', '')
  tel_no=xpathSApply(res, '//html/body/div/div/div[2]/div[1]/div[2]/div/div/div[1]/text()[3]', xmlValue)
  tel_no <- str_replace_all(tel_no, '(\r|\n| )+', '')
  #--------------------------------------------------------------------------------------
  FINISH= data.frame(brand_nm='JOHNNIE WALKER',store_nm=store_nm,addr=addr,tel_no=tel_no,data_dt=gsub('-','',Sys.Date()) ,stringsAsFactors=FALSE )
  #--------------------------------------------------------------------------------------
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.