Skip to content

Commit

Permalink
Update stf_download_details2.R
Browse files Browse the repository at this point in the history
  • Loading branch information
jjesusfilho authored Aug 4, 2024
1 parent 8116493 commit d517f3e
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions R/stf_download_details2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit d517f3e

Please sign in to comment.