-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
105 lines (74 loc) · 3.29 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# newscatcheR
<!-- badges: start -->
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/newscatcheR)](https://cran.r-project.org/package=newscatcheR)
[![CRAN\_Download\_Badge](https://cranlogs.r-pkg.org/badges/newscatcheR)](https://CRAN.R-project.org/package=newscatcheR)
[![CRAN\_Download\_Badge](https://cranlogs.r-pkg.org/badges/grand-total/newscatcheR)](https://CRAN.R-project.org/package=newscatcheR)
[![R-CMD-check](https://github.com/discindo/newscatcheR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/discindo/newscatcheR/actions/workflows/R-CMD-check.yaml)
![pkgdown](https://github.com/discindo/newscatcheR/workflows/pkgdown/badge.svg)
<!-- [![codecov](https://codecov.io/gh/discindo/newscatcheR/graph/badge.svg?token=u3BlKDT8b3)](https://codecov.io/gh/discindo/newscatcheR)>
<!-- badges: end -->
Programmatically collect normalized news from (almost) any website using R
newscatcheR is an R clone of the python package [newscatcher](https://github.com/kotartemiy/newscatcher).
The package provides a dataset of news sites and their rss feeds, together with some characteristics of the websites such as the topic, country or language of the website, and few functions explore and access the feeds from `R`.
Two functions that work as a wrapper around [tidyRSS](https://github.com/RobertMyles/tidyRSS) can be used to fetch the feed from a given website. Two additional functions can be used to conveniently browse the websites dataset.
## Installation
You can install the released version of newscatcheR from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("newscatcheR")
```
And the development version from [GitHub](https://github.com/) with:
```r
# install.packages("remotes")
remotes::install_github("discindo/newscatcheR")
```
Or
``` r
# install.packages("devtools")
devtools::install_github("discindo/newscatcheR")
```
## Overview
`get_news(website)` returns the contents of a rss feed of a website.
```{r example_1}
library(newscatcheR)
# adding a small time delay to avoid simultaneous posts to the API
Sys.sleep(3)
get_news("ycombinator.com")
```
`get_headlines(website)` returns just the headlines of the website's rss feed.
```{r example_2}
library(newscatcheR)
# adding a small time delay to avoid simultaneous posts to the API
Sys.sleep(3)
get_headlines("ycombinator.com")
```
`describe_url(website)` returns the topics of a given web site.
```{r example_3}
describe_url("bbc.com")
```
`filter_urls(topic, country, language )` can be used to browse the dataset by topic, country or language.
```{r example_4}
filter_urls(topic = "tech", country = "IT", language = "it")
```
## Use Case
This package can be convenient if you need to fetch news from various websites for further analysis and you don't want to search manually for the URL of their RSS feeds.
Assuming we have the news sites we want to follow:
```{r example5, eval = FALSE}
sites = c("bbc.com", "spiegel.de", "washingtonpost.com")
```
We can get a list of data frames with:
```{r example_6, eval = FALSE}
library(newscatcheR)
lapply(sites, get_news)
```