#' 7-ELEVEN
#'
#' 7-11 shop address.
#'
#' @return data.table
#' @export
get711 <- function() {
url <- "http://emap.pcsc.com.tw/EMapSDK.aspx"
res <- GET(url,
query = list(
commandid = "SearchStore",
StoreName = "%"
))
res_xml <- res %>%
content(encoding = "UTF-8") %>%
XML::xmlParse(encoding = "UTF-8", options = XML::HUGE) %>%
.['//GeoPosition']
dt_711 <- res_xml %>%
XML::xmlToDataFrame(stringsAsFactors = FALSE) %>%
as.data.table()
## Data cleansing
dt_711[
, c("X", "Y") := lapply(.SD,
function(x) {
as.numeric(as.character(x))*10^(-6)
}),
.SDcols = c("X", "Y")]
## add brand name, keyword
dt_711[, `:=`(brand_nm = "統一超商", keyword = "7-11")]
## rename variables
setnames(dt_711,
c("Address", "POIName", "Telno", "X", "Y"),
c("addr", "store_nm", "tel_no", "lon_x", "lat_y"))
# names(dt_711) %>% str_replace_all("([a-z])([A-Z])", "\\1_\\L\\2")
names(dt_711) <- names(dt_711) %>%
str_replace_all("([a-z])([A-Z])", "\\1_\\2") %>%
str_to_lower()
## add url, time, key
try({setnames(dt_711,"is7wi_fi", "is_7wifi")}, silent = T)
dt_711[, store_url := "http://emap.pcsc.com.tw/emap.aspx"]
dt_711[, data_time := format(Sys.time(), "%Y-%m-%dT%H:%M:%S%z")]
dt_711[, full_nm := paste0(brand_nm, store_nm)]
## move brand_nm, key_word to first two colmuns
setcolorder(dt_711, c("full_nm", "brand_nm", "keyword", "store_nm", "addr",
setdiff(names(dt_711), c("full_nm", "brand_nm", "keyword", "store_nm", "addr"))))
dt_711
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.