Collecting nytimes data.
You can install {nyt} from Github with:
devtools::install_github("mkearney/nyt")
This is a basic example showing how to search for articles from the US
section:
## basic example code
us1 <- nyt_articles(section = "us", page = 1)
## view data
us1
#> # A tibble: 10 x 17
#> first_publishedā¦ byline tone add_sort_date data_type data_id url created uri summary
#> * <lgl> <chr> <chr> <dttm> <chr> <chr> <chr> <dttm> <chr> <chr>
#> 1 NA By MIā¦ NEWS 2018-08-03 18:22:34 article 100000ā¦ httpā¦ 2018-08-03 18:22:34 nyt:ā¦ The faā¦
#> 2 NA By MAā¦ NEWS 2018-08-03 18:10:40 article 100000ā¦ httpā¦ 2018-08-03 18:10:40 nyt:ā¦ Prosecā¦
#> 3 NA By ANā¦ NEWS 2018-08-03 17:55:06 article 100000ā¦ httpā¦ 2018-08-03 17:55:06 nyt:ā¦ No faiā¦
#> 4 NA By JOā¦ NEWS 2018-08-03 17:18:09 article 100000ā¦ httpā¦ 2018-08-03 17:18:09 nyt:ā¦ Hereāsā¦
#> 5 NA By CHā¦ NEWS 2018-08-03 17:11:47 article 100000ā¦ httpā¦ 2018-08-03 17:11:47 nyt:ā¦ The inā¦
#> 6 NA By ANā¦ NEWS 2018-08-03 16:49:01 article 100000ā¦ httpā¦ 2018-08-03 16:49:01 nyt:ā¦ The Unā¦
#> 7 NA By JUā¦ NEWS 2018-08-03 16:36:10 article 100000ā¦ httpā¦ 2018-08-03 16:36:10 nyt:ā¦ A 187-ā¦
#> 8 NA By BRā¦ NEWS 2018-08-03 16:14:27 article 100000ā¦ httpā¦ 2018-08-03 16:14:27 nyt:ā¦ At theā¦
#> 9 NA By KAā¦ NEWS 2018-08-03 15:26:01 article 100000ā¦ httpā¦ 2018-08-03 15:26:01 nyt:ā¦ Their ā¦
#> 10 NA By MAā¦ NEWS 2018-08-03 14:12:29 article 100000ā¦ httpā¦ 2018-08-03 14:12:29 nyt:ā¦ The auā¦
#> # ... with 7 more variables: snippet <chr>, headline <chr>, print_information <lgl>,
#> # first_published_iso_timestamp <dttm>, kicker <chr>, publication_date <dttm>, body <chr>
And here is an example of fetching multiple pages of results from an
article search of the world
section:
## get multiple pages
w <- purrr::map(1:3, ~ nyt_articles(section = "world", page = .x))
## merge and view data
dplyr::bind_rows(w)
This is a basic example showing how to get the user/community comments associated with an articleās URL:
## basic example code
c1 <- nyt_comments(us1$url[9])
## view data
c1