Skip to content

Commit

Permalink
adds telegraaf.nl
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGruber committed Nov 2, 2023
1 parent e933273 commit 3e555cd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
49 changes: 49 additions & 0 deletions R/deliver_telegraaf_nl.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pb_deliver_paper.telegraaf_nl <- function(x, verbose = NULL, pb, ...) {

# raw html is stored in column content_raw
html <- rvest::read_html(x$content_raw)
pb_tick(x, verbose, pb)

# datetime
datetime <- html %>%
rvest::html_element("[property=\"article:published_time\"]") %>%
rvest::html_attr("content") %>%
lubridate::as_datetime()

# headline
headline <- html %>%
rvest::html_element("[name=\"title\"]") %>%
rvest::html_attr("content")

# author
author <- html %>%
rvest::html_element(".DetailBylineBlock__author") %>%
rvest::html_text2() %>%
toString()

# text
text <- html %>%
rvest::html_elements(".Article__intro,.DetailBodyBlocks p") %>%
rvest::html_text2() %>%
paste(collapse = "\n")

cover_image_html <- html %>%
rvest::html_element(".DetailArticleImage img") %>%
as.character()

cover_image_url <- html %>%
rvest::html_element(".DetailArticleImage img") %>%
rvest::html_attr("src") %>%
paste0("https://www.telegraaf.nl", .)

# the helper function safely creates a named list from objects
s_n_list(
datetime,
author,
headline,
text,
cover_image_url,
cover_image_html
)

}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ therefore often encounter this warning:

``` r
pb_deliver("google.com")
#> Warning: ℹ No parser for domain google.com yet, attempting generic approach.
#> ! No parser for domain google.com yet, attempting generic approach.
```

| url | expanded_url | domain | status | datetime | author | headline | text | misc |
Expand Down Expand Up @@ -163,6 +163,7 @@ column was included so these can be retained.
| seznamzpravy.cz | ![](https://img.shields.io/badge/status-gold-%23ffd700.svg) | [@JBGruber](https://github.com/JBGruber/) | |
| sfgate.com | ![](https://img.shields.io/badge/status-gold-%23ffd700.svg) | [@JBGruber](https://github.com/JBGruber/) | |
| skwawkbox.org | ![](https://img.shields.io/badge/status-gold-%23ffd700.svg) | [@JBGruber](https://github.com/JBGruber/) | |
| telegraaf.nl | ![](https://img.shields.io/badge/status-silver-%23C0C0C0.svg) | [@JBGruber](https://github.com/JBGruber/) | [\#17](https://github.com/JBGruber/paperboy/issues/17) |
| telegraph.co.uk | ![](https://img.shields.io/badge/status-gold-%23ffd700.svg) | [@JBGruber](https://github.com/JBGruber/) | |
| thecanary.co | ![](https://img.shields.io/badge/status-gold-%23ffd700.svg) | [@JBGruber](https://github.com/JBGruber/) | |
| theguardian.com | ![](https://img.shields.io/badge/status-gold-%23ffd700.svg) | [@JBGruber](https://github.com/JBGruber/) | |
Expand Down
1 change: 1 addition & 0 deletions inst/status.csv
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"seznamzpravy.cz","![](https://img.shields.io/badge/status-gold-%23ffd700.svg)","[@JBGruber](https://github.com/JBGruber/)","","https://www.seznamzpravy.cz/rss"
"sfgate.com","![](https://img.shields.io/badge/status-gold-%23ffd700.svg)","[@JBGruber](https://github.com/JBGruber/)","",NA
"skwawkbox.org","![](https://img.shields.io/badge/status-gold-%23ffd700.svg)","[@JBGruber](https://github.com/JBGruber/)","",NA
"telegraaf.nl","![](https://img.shields.io/badge/status-silver-%23C0C0C0.svg)","[@JBGruber](https://github.com/JBGruber/)","[#17](https://github.com/JBGruber/paperboy/issues/17)","https://www.telegraaf.nl/rss.xml"
"telegraph.co.uk","![](https://img.shields.io/badge/status-gold-%23ffd700.svg)","[@JBGruber](https://github.com/JBGruber/)","",NA
"thecanary.co","![](https://img.shields.io/badge/status-gold-%23ffd700.svg)","[@JBGruber](https://github.com/JBGruber/)","",NA
"theguardian.com","![](https://img.shields.io/badge/status-gold-%23ffd700.svg)","[@JBGruber](https://github.com/JBGruber/)","",NA
Expand Down

0 comments on commit 3e555cd

Please sign in to comment.