kr.Investing.com 06_07

김오왼·2022년 6월 7일
0


library(rvest)
library(RSelenium)
library(httr)
library(dplyr) 

kr.investing_0607 <- 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_0607 <- c(kr.investing_0607,text_title)
  }
} 


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

0개의 댓글