diff --git a/R/features.R b/R/features.R index 7bf88f62..706d991d 100644 --- a/R/features.R +++ b/R/features.R @@ -23,7 +23,7 @@ available_features <- function () { pg <- httr2::resp_body_html (resp) keys <- xml2::xml_attr ( - rvest::html_nodes (pg, "a[href^='/wiki/Key']"), # nolint + rvest::html_elements (pg, "a[href^='/wiki/Key']"), # nolint "href" ) %>% strsplit ("/wiki/Key:") %>% @@ -115,7 +115,7 @@ get_all_tags <- function (pg) { #' @noRd tags_from_taglists <- function (pg) { - taglists <- rvest::html_nodes (pg, "div[class='taglist']") %>% + taglists <- rvest::html_elements (pg, "div[class='taglist']") %>% rvest::html_attr ("data-taginfo-taglist-tags") taglists <- lapply (taglists, function (i) { diff --git a/tests/testthat/test-features.R b/tests/testthat/test-features.R index ad3ac5a1..75d2c2e2 100644 --- a/tests/testthat/test-features.R +++ b/tests/testthat/test-features.R @@ -18,7 +18,7 @@ test_that ("available_features", { recursive = TRUE ) [1] x <- xml2::read_html (fname) - nodes_all <- rvest::html_nodes (x, "td") + nodes_all <- rvest::html_elements (x, "td") nodes_sample <- nodes_all [1:20] writeLines (as.character (nodes_sample), fname) } @@ -43,10 +43,10 @@ post_process_tags <- function (dir_name, keys = "building") { x <- xml2::read_html (fname) - nodes_sample <- rvest::html_nodes (x, "div[class='taglist']") [1:10] + nodes_sample <- rvest::html_elements (x, "div[class='taglist']") [1:10] - tables_sample <- rvest::html_nodes (x, "table") - tables_r <- rvest::html_table (tables_sample) + tables <- rvest::html_elements (x, "table") + tables_r <- rvest::html_table (tables) index <- which (vapply (tables_r, function (i) { ret <- FALSE if ("Key" %in% names (i)) { @@ -54,26 +54,13 @@ post_process_tags <- function (dir_name, keys = "building") { } return (ret) }, logical (1L))) - tables_sample <- tables_sample [index] - - # table_rows <- xml2::xml_find_all (tables_sample, "//tr") - # table_rows <- table_rows [grep (keys, table_rows) [1:10]] - # TODO: Figure out how to re-insert these table rows back into document - - # A hacky way to reduce number of table nodes, by replacing lines in the - # text file: - ftmp <- tempfile (fileext = ".html") - writeLines (as.character (tables_sample), ftmp) - tmp <- readLines (ftmp) - index0 <- grep ("