R/webscrap_bible.R

Defines functions webscrap_bible

#' webscrap_bible
#'
#' @description Funcao para montagem da tabela de versiculos da biblia
#'
#' @return Um dataframe com todos os versiculos da biblia ACF, Almeida 
#' Corrigida e Fiel
#' 
#'
#' @noRd
webscrap_bible <- function() {
  
  bible <- suppressWarnings(jsonlite::fromJSON("https://raw.githubusercontent.com/thiagobodruk/biblia/master/json/acf.json"))
  names(bible$chapters) <- bible$name
  
  bible <- purrr::map_dfr(bible$chapters, \(book) {
    names(book) <- 1:length(book)
    new_book <- purrr::map(book, \(chapter) {
      purrr::imap_chr(chapter, \(verse, i) {
        glue::glue("{i}. {verse}")
      }) |> paste0(collapse = "\n\n")
    })
    tibble::tibble(chapter = names(new_book), verses = unlist(new_book))
  }, .id = "book")
  
}
damarals/gospel.slides documentation built on March 19, 2022, 10:50 a.m.