NEWS API 에서 Key 를 받아 전세계 언론사에서 배포된 기사를 R에서 수월하게 받아 볼 수 있다. R 패키지 newsapi는 R에서 바로 작업을 수월하게 할 수 있도록 도움을 준다.
미리 API키를 NEWS API 웹사이트에서 발급받아 usethis::edit_r_environ() 명령어로 /Users/사용자명/.Renviron 파일에 저장을 해둔다.
library(tidyverse)
library(newsapi)
newsapi_key(Sys.getenv("NEWSAPI_KEY"))
# news_sources()
# top_headlines("Squid Game")
squid_tbl <- every_news("Squid Game")
squid_tbl %>%
arrange(desc(publishedAt)) %>%
select(source, title, content) %>%
reactable::reactable()news_sources() %>%
reactable::reactable()# top_headlines("lee jae-myung")
top_headlines("Korea") %>%
select(source, title, content) %>%
reactable::reactable()korea_tbl <- every_news("Korea", since = "2021-10-01", until = "2021-10-31")
korea_tbl %>%
select(source, title, content, publishedAt) %>%
reactable::reactable()데이터 과학자 이광춘 저작
kwangchun.lee.7@gmail.com