draft/getSteakMyHome.R

getSteakMyHome <- function(){
  
  url      <- 'http://steakmyhome.com.tw/js/model/store/ShopModel.js'
  htmldoc1 <- content(GET(url, encoding='utf8'), as='text', encoding='utf8')
  info1    <- str_replace(htmldoc1,'defaults:','   ') 
  info2    <- str_split(info1,"\n")[[1]]
  info3    <- str_replace(str_replace(str_extract(info2,'defaults.+'),'(defaults:\\{)',''),',describe.+','')  
  info4    <- str_replace_all(info3,',','  ')
  info5    <- unlist(str_split(na.exclude(info4)," "))
  info6    <- gsub("locname:|storename:|storenumber:|storeaddress:|'|\\(無沙拉吧\\)","",info5)
  info7    <- info6[-which(info6=="")]
  info8    <- as.data.frame(matrix(info7, ncol=4, byrow=TRUE), stringsAsFactors = FALSE)
  
  info9    <- data.frame('我家牛排',info8)
  names(info9) <- c('brand_nm','city','store_nm','tel_no','addr')
  info9
}
leoluyi/CRMaddress documentation built on May 21, 2019, 5:08 a.m.