Skip to content

Instantly share code, notes, and snippets.

@mrchypark
Last active June 2, 2019 15:06
Show Gist options
  • Save mrchypark/ba990f16feb0546ce0f76dff29fa2578 to your computer and use it in GitHub Desktop.
Save mrchypark/ba990f16feb0546ce0f76dff29fa2578 to your computer and use it in GitHub Desktop.
library(httr)
library(rvest)
library(dplyr)
tar <- "https://finance.naver.com/marketindex/exchangeList.nhn"
Sys.setlocale("LC_ALL", "C")
read_html(tar, encoding = "euc-kr") %>%
html_nodes("table.tbl_exchange") %>%
html_table(fill=T) %>%
.[[1]] ->
exc
Sys.setlocale("LC_ALL", "Korean_Korea.949")
na1 <- names(exc)
na2 <- exc %>%
rowwise() %>%
slice(1) %>%
as.character()
names(exc)[3] <- "현찰 사실 때"
names(exc)[4] <- "현찰 파실 때"
names(exc)[5] <- "송금 보내실 때"
names(exc)[6] <- "송금 받으실 때"
exc %>%
slice(-1) ->
exc
tar <- "https://finance.naver.com/marketindex/"
read_html(tar, encoding = "euc-kr") %>%
html_nodes("div.exchange_info span") %>%
html_text -> dat_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment