getSampo <- function(){
wantURL <- 'http://www.sampo.com.tw/storefinder.aspx?storetype=%E7%B6%93%E9%8A%B7%E5%BA%97'
res <- GET(wantURL, encoding='utf8')
res2 <- htmlParse(res, encoding='utf8')
store_nm=xpathSApply(res2, '//*[@id="StoreList"]/dl/dd/span[1]', xmlValue)
store_nm <- str_replace_all(store_nm, '(\r|\n| | )+', '')
addr=xpathSApply(res2, '//*[@id="StoreList"]/dl/dd/span[2]', xmlValue)
addr <- str_replace_all(addr, '(\r|\n| | )+', '')
addr <- str_replace_all(addr, '([(]).+$', '')
tel_no=xpathSApply(res2, '//*[@id="StoreList"]/dl/dd/span[3]', xmlValue)
tel_no <- str_replace_all(tel_no, '(\r|\n| | )+', '')
OUTPUT= data.frame(brand_nm='聲寶',store_nm=store_nm,addr=addr,tel_no=tel_no, data_dt=gsub('-','',Sys.Date()) ,stringsAsFactors=FALSE )
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.