![](https://velog.velcdn.com/images/xowen96/post/920ea5fb-f06c-4e15-9bc9-002aeac0decd/image.png)
![](https://velog.velcdn.com/images/xowen96/post/4d42336e-67c4-4047-b42f-66a29e1cd02a/image.png)
![](https://velog.velcdn.com/images/xowen96/post/c98749ac-1cd2-473c-b870-acf2b98ddb94/image.png)
library(rvest)
library(RSelenium)
library(httr)
library(dplyr)
News_0607 <- NULL
for (pageNo in 1:10) {
urls <- paste0("https://news.naver.com/main/list.naver?mode=LS2D&mid=shm&sid2=258&sid1=101&date=20220607&page=",pageNo)
html_source <- read_html(urls)
for (i in 1:20) {
T.selector <- paste0("#main_content > div.list_body.newsflash_body > ul.type06_headline > li:nth-child(",i,") > dl > dt:nth-child(2) > a")
title_nodes <- html_nodes(html_source,T.selector)
text_title <- html_text(title_nodes)
News_0607 <- c(News_0607,text_title)
}
}
df <- data.frame(News_0607)
df[,1]<- gsub("\t","",df[,1])
df[,1]<- gsub("\n","",df[,1])
df[,1]<- gsub(" ","",df[,1])
df