-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from schochastics/german_media
add german media (#23)
- Loading branch information
Showing
101 changed files
with
3,152 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,16 @@ Title: Comprehensive Collection of News Media Scrapers | |
Version: 0.0.7.9000 | ||
Date: 2024-07-17 | ||
Authors@R: | ||
person(given = "Johannes B.", | ||
family = "Gruber", | ||
email = "[email protected]", | ||
role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0001-9177-1772")) | ||
c(person(given = "Johannes B.", | ||
family = "Gruber", | ||
email = "[email protected]", | ||
role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0001-9177-1772")), | ||
person(given = "David", | ||
family = "Schoch", | ||
email = "[email protected]", | ||
role = "ctb", | ||
comment = c(ORCID = "0000-0003-2952-4812"))) | ||
Description: A comprehensive collection of webscraping scripts for news media sites. | ||
Depends: | ||
R (>= 3.5.0) | ||
|
@@ -44,6 +49,6 @@ Suggests: | |
URL: https://github.com/JBGruber/paperboy | ||
Encoding: UTF-8 | ||
BugReports: https://github.com/JBGruber/paperboy/issues | ||
RoxygenNote: 7.3.1 | ||
RoxygenNote: 7.3.2 | ||
VignetteBuilder: knitr | ||
Language: en-GB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' @export | ||
pb_deliver_paper.3sat_de <- function(x, verbose = NULL, pb, ...) { | ||
pb_tick(x, verbose, pb) | ||
# raw html is stored in column content_raw | ||
html <- rvest::read_html(x$content_raw) | ||
datetime <- html %>% | ||
rvest::html_elements("time") %>% | ||
rvest::html_attr("datetime") %>% | ||
lubridate::as_datetime() | ||
|
||
headline <- html %>% | ||
rvest::html_elements(".main-content-details h2") %>% | ||
rvest::html_text() | ||
|
||
author <- "" # no author info found | ||
|
||
text <- html %>% | ||
rvest::html_elements(".o--post-long p") %>% | ||
rvest::html_text2() %>% | ||
paste(collapse = "\n") | ||
|
||
s_n_list( | ||
datetime, | ||
author, | ||
headline, | ||
text | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' @export | ||
pb_deliver_paper.abendblatt_de <- function(x, verbose = NULL, pb, ...) { | ||
pb_tick(x, verbose, pb) | ||
# raw html is stored in column content_raw | ||
html <- rvest::read_html(x$content_raw) | ||
|
||
json_txt <- rvest::html_elements(html, "script[type = \"application/ld+json\"] ") %>% rvest::html_text() | ||
if (isTRUE(is.na(json_txt)) || length(json_txt) == 0) { | ||
return(s_n_list()) | ||
} else { | ||
json_df <- jsonlite::fromJSON(json_txt[2]) | ||
|
||
datetime <- lubridate::as_datetime(json_df$datePublished) | ||
headline <- json_df$headline | ||
author <- toString(json_df$author$name) | ||
text <- html %>% | ||
rvest::html_elements(".article-body h3, .article-body p") %>% | ||
rvest::html_text2() %>% | ||
paste(collapse = "\n") | ||
|
||
s_n_list( | ||
datetime, | ||
author, | ||
headline, | ||
text | ||
) | ||
} | ||
} | ||
# rss feed includes pages that cannot be parsed because they are subpages | ||
# rss feed also includes podcast, which cannot be parsed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' @export | ||
pb_deliver_paper.abendzeitung_muenchen_de <- function(x, verbose = NULL, pb, ...) { | ||
pb_tick(x, verbose, pb) | ||
# raw html is stored in column content_raw | ||
html <- rvest::read_html(x$content_raw) | ||
|
||
json_txt <- rvest::html_elements(html, "script[type = \"application/ld+json\"] ") %>% rvest::html_text() | ||
if (isTRUE(is.na(json_txt)) || length(json_txt) == 0) { | ||
return(s_n_list()) | ||
} else { | ||
json_df <- jsonlite::fromJSON(json_txt[1]) | ||
|
||
datetime <- lubridate::as_datetime(json_df$datePublished) | ||
headline <- json_df$headline | ||
author <- toString(json_df$author$name) | ||
text <- html %>% | ||
rvest::html_elements(".artdetail_short ,.artdetail_text p,.artdetail_text h2") %>% | ||
rvest::html_text2() %>% | ||
paste(collapse = "\n") | ||
|
||
s_n_list( | ||
datetime, | ||
author, | ||
headline, | ||
text | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#' @export | ||
pb_deliver_paper.augsburger_allgemeine_de <- function(x, verbose = NULL, pb, ...) { | ||
pb_tick(x, verbose, pb) | ||
# raw html is stored in column content_raw | ||
html <- rvest::read_html(x$content_raw) | ||
|
||
|
||
datetime <- html %>% | ||
rvest::html_element("time") %>% | ||
rvest::html_attr("datetime") %>% | ||
lubridate::as_datetime() | ||
headline <- html %>% | ||
rvest::html_element("h2.typo-teaserheadline-SoleXL, h2.typo-articleheadline-Recife") %>% | ||
rvest::html_text() | ||
author <- html %>% | ||
rvest::html_elements("a.typo-author-link") %>% | ||
rvest::html_text2() %>% | ||
toString() | ||
text <- html %>% | ||
rvest::html_elements(".typo-article-teaser-Recife, .typo-article-teaser, .article-body-paid-content, .typo-subhead, p.text-xs") %>% | ||
rvest::html_text2() %>% | ||
unique() %>% # teaser might be duplicated | ||
paste(collapse = "\n") | ||
|
||
s_n_list( | ||
datetime, | ||
author, | ||
headline, | ||
text | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' @export | ||
pb_deliver_paper.badische_zeitung_de <- function(x, verbose = NULL, pb, ...) { | ||
pb_tick(x, verbose, pb) | ||
# raw html is stored in column content_raw | ||
html <- rvest::read_html(iconv(x$content_raw, from = "ISO-8859-1", to = "UTF-8")) | ||
|
||
json_txt <- rvest::html_elements(html, "script[type = \"application/ld+json\"] ") %>% rvest::html_text() | ||
if (isTRUE(is.na(json_txt)) || length(json_txt) == 0) { | ||
return(s_n_list()) | ||
} else { | ||
json_df <- jsonlite::fromJSON(json_txt[1]) | ||
|
||
datetime <- lubridate::as_datetime(json_df$datePublished) | ||
headline <- json_df$headline | ||
author <- toString(json_df$author) | ||
text <- html %>% | ||
rvest::html_elements("section[role = \"article\"], .article-site__topic") %>% | ||
rvest::html_text2() %>% | ||
paste(collapse = "\n") | ||
|
||
s_n_list( | ||
datetime, | ||
author, | ||
headline, | ||
text | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#' @export | ||
pb_deliver_paper.berliner_kurier_de <- function(x, verbose = NULL, pb, ...) { | ||
pb_tick(x, verbose, pb) | ||
# raw html is stored in column content_raw | ||
html <- rvest::read_html(x$content_raw) | ||
|
||
json_txt <- rvest::html_elements(html, "script[type = \"application/ld+json\"] ")[1] %>% rvest::html_text() | ||
json_df <- jsonlite::fromJSON(json_txt) | ||
|
||
datetime <- lubridate::as_datetime(json_df$datePublished) | ||
headline <- json_df$headline | ||
author <- toString(json_df$author$name) | ||
text <- html %>% | ||
rvest::html_elements(".article_header-lead__0E3Bn, p.article_paragraph__hXYKJ, h2.article_subtitle__wx1Lu") %>% | ||
rvest::html_text2() %>% | ||
paste(collapse = "\n") | ||
|
||
s_n_list( | ||
datetime, | ||
author, | ||
headline, | ||
text | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' @export | ||
pb_deliver_paper.berliner_zeitung_de <- function(x, verbose = NULL, pb, ...) { | ||
pb_tick(x, verbose, pb) | ||
# raw html is stored in column content_raw | ||
html <- rvest::read_html(x$content_raw) | ||
|
||
json_txt <- rvest::html_elements(html, "script[type = \"application/ld+json\"] ") %>% rvest::html_text() | ||
if (isTRUE(is.na(json_txt)) || length(json_txt) == 0) { | ||
return(s_n_list()) | ||
} else { | ||
json_df <- jsonlite::fromJSON(json_txt[1]) | ||
|
||
datetime <- lubridate::as_datetime(json_df$datePublished) | ||
headline <- json_df$headline | ||
author <- toString(json_df$author$name) | ||
text <- html %>% | ||
rvest::html_elements(".article_paragraph__hXYKJ") %>% | ||
rvest::html_text2() %>% | ||
paste(collapse = "\n") | ||
|
||
s_n_list( | ||
datetime, | ||
author, | ||
headline, | ||
text | ||
) | ||
} | ||
} |
Oops, something went wrong.