From d517f3e9ad4154ea3fb9430a2c33712c083f5278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20de=20Jesus=20Filho?= Date: Sun, 4 Aug 2024 16:24:15 -0300 Subject: [PATCH] Update stf_download_details2.R --- R/stf_download_details2.R | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/R/stf_download_details2.R b/R/stf_download_details2.R index 50a32aa..a046194 100644 --- a/R/stf_download_details2.R +++ b/R/stf_download_details2.R @@ -9,39 +9,36 @@ #' @export #' stf_download_details2 <- function(class = NULL, docket_number = NULL,dir = "."){ - + urls <- paste0( "http://portal.stf.jus.br/processos/listarProcessos.asp?classe=", class, "&numeroProcesso=", docket_number ) - - - pb <- progress::progress_bar$new(total = length(urls)) + + +httr::set_config(httr::config(ssl_verifypeer = FALSE)) incidente <- purrr::map(urls,purrr::possibly(~{ - - - pb$tick() - - resposta <- .x %>% - httr::RETRY("GET",., + + resposta <- .x |> + httr::RETRY("GET",url = _, httr::user_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36") - - ) - - incidente <- resposta$url %>% - stringr::str_extract("\\d+") - + + ) + + incidente <- resposta$url |> + stringr::str_extract("\\d+$") + arquivo <- paste0(dir, format(Sys.Date(), "/date_%Y_%m_%d_incidente_"),incidente, ".html") - + writeBin(resposta$content,arquivo) - + incidente - - },NULL)) %>% + + },NULL), .progress = TRUE) |> unlist() - + return(incidente) }