kr.Investing.com 05_25

김오왼·2022년 5월 25일
0





kr.investing_0525 <- c()
news_href <- c()

for (pageNo in 1) {
  urls <- paste0("https://kr.investing.com/news/stock-market-news/",pageNo)
  get_url <- GET(urls)
  html_source <- read_html(get_url)
  my_nodes <- html_nodes(html_source,".textDiv > a.title")
  my_href <- html_attr(my_nodes,"href")
  news_href <- paste0("https://kr.investing.com",my_href) 
  
  
  for (i in 1:36) {  
  
    T.selector <- paste0("#leftColumn > div.largeTitle > article:nth-child(",i,") > div.textDiv > a")
    title_nodes <- html_nodes(html_source,T.selector)
    text_title <- html_text(title_nodes)
    kr.investing_0525 <- c(kr.investing_0525,text_title)
  }
} 


df <- data.frame(kr.investing_0525)
href_df <- data.frame(news_href)
df
profile
전문 금융인을 목표로하는 김야옹야옹이

0개의 댓글