getALaSha <- function(){
#家族遊樂園
res=htmlParse('http://www.alasha.com.tw/store.php?s=1', encoding='utf8')
門市 <- xpathSApply(res, '//*[@class="store_title"]', xmlValue)
營業時間 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[1]/td[2]', xmlValue)
營業時間 <- str_replace_all(營業時間, '(\r|\n| |[營業時間 ])+', '')
電話 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[2]/td[1]', xmlValue)
電話 <- str_replace_all(電話, '(\r|\n| |[電話 ])+', '')
地址 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[3]/td[1]', xmlValue)
地址 <- str_replace_all(地址, '(\r|\n| |[地址 ])+', '')
地址 <- str_replace_all(地址, '([(]).+$', '')
OUTPUT1=data.frame(type='家族遊樂園',store_nm=門市,addr=地址,tel_no=電話,open_time=營業時間,data_dt=gsub('-','',Sys.Date()), stringsAsFactors = FALSE)
#尋寶樂園
res=htmlParse('http://www.alasha.com.tw/store.php?s=2', encoding='utf8')
門市 <- xpathSApply(res, '//*[@class="store_title"]', xmlValue)
營業時間 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[1]/td[2]', xmlValue)
營業時間 <- str_replace_all(營業時間, '(\r|\n| |[營業時間 ])+', '')
電話 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[2]/td[1]', xmlValue)
電話 <- str_replace_all(電話, '(\r|\n| |[電話 ])+', '')
地址 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[3]/td[1]', xmlValue)
地址 <- str_replace_all(地址, '(\r|\n| |[地址 ])+', '')
地址 <- str_replace_all(地址, '([(]).+$', '')
OUTPUT2=data.frame(type='尋寶樂園',store_nm=門市,addr=地址,tel_no=電話,open_time=營業時間,data_dt=gsub('-','',Sys.Date()), stringsAsFactors = FALSE)
#百貨專櫃區
res=htmlParse('http://www.alasha.com.tw/store.php?s=3', encoding='utf8')
門市 <- xpathSApply(res, '//*[@class="store_title"]', xmlValue)
營業時間 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[1]/td[2]', xmlValue)
營業時間 <- str_replace_all(營業時間, '(\r|\n| |[營業時間 ])+', '')
電話 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[2]/td[1]', xmlValue)
電話 <- str_replace_all(電話, '(\r|\n| |[電話 ])+', '')
地址 <- xpathSApply(res, '//*[@class="store_detail_info"]/table/tr[3]/td[1]', xmlValue)
地址 <- str_replace_all(地址, '(\r|\n| |[地址 ])+', '')
地址 <- str_replace_all(地址, '([(]).+$', '')
OUTPUT3=data.frame(type='百貨專櫃區',store_nm=門市,addr=地址,tel_no=電話,open_time=營業時間,data_dt=gsub('-','',Sys.Date()), stringsAsFactors = FALSE)
OUTPUT=rbind(OUTPUT1, OUTPUT2, OUTPUT3)
OUTPUT= data.frame(brand_nm='a la sha', OUTPUT, stringsAsFactors=FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.