draft/getEasyrent.R

getEasyrent <- function(){
  res <- GET("https://www.easyrent.com.tw/WEB101.aspx")
  res <- htmlParse(content(res,'text', encoding = 'utf8'), encoding = 'utf8')
  area <- xpathSApply(res, '//*[@id="form1"]/table/tr/td[1]',xmlValue)
  area <- str_replace_all(area, ' ', '')
  store_nm <- xpathSApply(res, '//*[@id="form1"]/table/tr/td[2]',xmlValue)
  store_nm <- str_replace_all(store_nm, ' |\r|\t|\n', '')
  open <- xpathSApply(res, '//*[@id="form1"]/table/tr/td[4]',xmlValue)
  open <- str_replace_all(open, ' |\r|\t|\n|-', '')
  tel_no <- xpathSApply(res, '//*[@id="form1"]/table/tr/td[3]',xmlValue)
  tel_no <- str_replace_all(tel_no, ' |\r|\t|\n|-', '')
  addr <- xpathSApply(res, '//*[@id="form1"]/table/tr/td[5]',xmlValue)
  addr <- str_replace_all(addr, ' |\r|\t|\n|', '')
  addr <- str_replace_all(addr, '\\(.+', '')
  result <- data.frame(brand_nm='和運租車', store_nm, tel_no, addr, open, area, stringsAsFactors = FALSE)
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.