![](https://velog.velcdn.com/images/xowen96/post/68c1aef9-14ac-4e0a-9ad2-5b0b51790b04/image.png)
![](https://velog.velcdn.com/images/xowen96/post/00a903a5-1ad9-45cd-b252-e57db218a063/image.png)
![](https://velog.velcdn.com/images/xowen96/post/413a110a-9c10-433d-b056-9e48e33996f0/image.png)
![](https://velog.velcdn.com/images/xowen96/post/77dfed57-9748-48aa-aa54-91cd63181fd4/image.png)
library(rvest)
library(RSelenium)
library(httr)
library(dplyr)
News_0527 <- NULL
for (pageNo in 1:10) {
urls <- paste0("https://news.naver.com/main/list.naver?mode=LS2D&mid=shm&sid2=258&sid1=101&date=20220527&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_0527 <- c(News_0527,text_title)
}
}
df <- data.frame(News_0527)
df[,1]<- gsub("\t","",df[,1])
df[,1]<- gsub("\n","",df[,1])
df[,1]<- gsub(" ","",df[,1])
df