draft/get3m.R

get3m <- function(){
  wantURL <- 'http://solutions.3m.com.tw/wps/portal/3M/zh_TW/TWCHIMPurewater/home/w/whereToBuy2/'
  res=htmlParse(wantURL, encoding='utf8')
  
  store_nm=xpathSApply(res, '//*[@class="ui-block-a"]/a', xmlValue)
  addr=xpathSApply(res, '//*[@class="ui-grid-a ui-responsive"]/div[@class="ui-block-b"]/text()', xmlValue)
  addr <- str_replace_all(addr, '(\r|\n| |\t)+', '')
  addr=addr[addr!='']
  
  FINISH= data.frame(brand_nm='3M',store_nm=store_nm,addr=addr, data_dt=gsub('-','',Sys.Date()) ,stringsAsFactors=FALSE )
  return(FINISH)
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.