getZurich <- function(){
##蘇黎世產險
url_A <-c("https://www.zurich.com.tw/ZurichWeb/home/Station/station_N.htm",
"https://www.zurich.com.tw/ZurichWeb/home/Station/station_C.htm",
"https://www.zurich.com.tw/ZurichWeb/home/Station/station_S.htm",
"https://www.zurich.com.tw/ZurichWeb/home/Station/station_E.htm")
mylist <- list()
for (i in 1:4){
url <- url_A[i]
res <- GET(url, encoding='utf8')
res2 <- content(res,"text", encoding='utf8')
html <- htmlParse(res2, encoding = "utf8")
tables <- readHTMLTable(html)
data <- tables[[6]]
data1 <- data[-1,]
mylist=rbind(mylist,data1)
}
tel<-mylist[,4]
tel1 <-str_replace_all(unlist(tel),'\r\n', "")
fax<-mylist[,5]
fax1 <-str_replace_all(unlist(fax),'\r\n', "")
data01 = data.frame('蘇黎世產險', mylist[,1], unlist(tel1), unlist(fax1), mylist[,3], stringsAsFactors=FALSE)
data_zur <- data01[,-6]
colnames(data_zur) = c("brand_nm", "store_nm", "tel_no", "fax_no", "addr")
return(data_zur)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.