draft/getArtsTicket.R

getArtsTicket <- function(){
  res <- GET("http://www.artsticket.com.tw/CKSCC2005/buyinfo/buyinfo00/sitelist.aspx")
  res <- htmlParse(content(res,'text', encoding = 'utf8'), encoding = 'utf8')
  
  store_nm=xpathSApply(res, '//*[@id="ctl00_middleContent_dlArea"]/tr/td/table/tr/td[1]', xmlValue)
  store_nm <- str_replace_all(store_nm, '(\r|\n|\t)+', '')
  store_nm=store_nm[store_nm!='店名']
  addr=xpathSApply(res, '//*[@id="ctl00_middleContent_dlArea"]/tr/td/table/tr/td[2]', xmlValue)
  addr <- str_replace_all(addr, '([(]).+$', '')
  addr <- str_replace_all(addr, '(\r|\n|\t)+', '')
  addr=addr[addr!='地址']
  tel_no=xpathSApply(res, '//*[@id="ctl00_middleContent_dlArea"]/tr/td/table/tr/td[3]', xmlValue)
  tel_no <- str_replace_all(tel_no, '(\r|\n|\t)+', '')
  tel_no <- str_replace_all(tel_no, '([(]).+$', '')
  tel_no=tel_no[tel_no!='聯絡電話']
  open_time=xpathSApply(res, '//*[@id="ctl00_middleContent_dlArea"]/tr/td/table/tr/td[4]', xmlValue)
  open_time <- str_replace_all(open_time, '(\r|\n|\t)+', '')
  open_time=open_time[open_time!='售取票服務時間']
  FINISH= data.frame(brand_nm='兩廳院售票',store_nm=store_nm,addr=addr,tel_no=tel_no,open_time=open_time, data_dt=gsub('-','',Sys.Date()) ,stringsAsFactors=FALSE )
  return(FINISH)
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.