Skip to content

Commit

Permalink
Update tjsp_baixar_cpopg_docs_cd_processo.R
Browse files Browse the repository at this point in the history
  • Loading branch information
jjesusfilho authored Mar 4, 2024
1 parent 3d07277 commit 30ebc06
Showing 1 changed file with 62 additions and 62 deletions.
124 changes: 62 additions & 62 deletions R/tjsp_baixar_cpopg_docs_cd_processo.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,57 @@
#' @return pdfs
#' @export
#'
tjsp_baixar_cpopg_docs_cd_processo <- function(df,diretorio = "."){

tjsp_baixar_docs_cd_processo <- function(df,diretorio = "."){
lista <- df |>
dplyr::group_split(cd_processo)


dplyr::group_split(cd_processo_pg)
httr::set_config(httr::config(ssl_verifypeer = FALSE))


uri1 <- "https://esaj.tjsp.jus.br/cpopg/search.do?gateway=true"



uri_pg <- "https://esaj.tjsp.jus.br/cpopg/search.do?gateway=true"

uri_sg <- "https://esaj.tjsp.jus.br/cposg/search.do?gateway=true"


pb <- progress::progress_bar$new(total = length(lista))


purrr::walk(lista, purrr::possibly(~{

pb$tick()

dd <- .x

cd_processo <- .x$cd_processo |> unique()

conteudo <- cd_processo |>
paste0("https://esaj.tjsp.jus.br/cpopg/show.do?processo.codigo=", ... = _, "&gateway=true") |>


cd_processo <- .x$cd_processo_pg |> unique()


if (!all(is.na(.x$cd_processo_sg))) {

sg <- unique(.x$cd_processo_sg)

r1 <- httr::GET(paste0("https://esaj.tjsp.jus.br/cposg/show.do?processo.codigo=",sg , "&gateway=true"))

url1 <- paste0("https://esaj.tjsp.jus.br/cposg/verificarAcessoPastaDigital.do?cdProcesso=", sg,"&conversationId=&_=1599440192646")


} else {


url1 <- paste0("https://esaj.tjsp.jus.br/cpopg/abrirPastaDigital.do?processo.codigo=",cd_processo)

}

r2 <- url1 |>
httr::GET() |>
httr::content()


if (
conteudo |>
xml2::xml_find_first("boolean(//a[@class='linkConsultaSG btn btn-secondary btn-space'])")
) {

url1 <- paste0("https://esaj.tjsp.jus.br/cposg/verificarAcessoPastaDigital.do?cdProcesso=", cd_processo,"&conversationId=&_=1599440192646")

} else {


url1 <- paste0("https://esaj.tjsp.jus.br/cpopg/abrirPastaDigital.do?processo.codigo=",cd_processo)

}

r2 <- url1 |>
httr::GET() |>
httr::content("text") |>
httr::GET()

tjsp_baixar_docs_cd_processo(dd$cd_processo, dd$id_doc, dd$pagina_inicial, dd$url_doc, diretorio)


},NULL))

httr::content("text") |>
httr::GET()

tjsp_baixar_docs_cd_processo1(.x$cd_processo_pg, .x$id_doc, .x$pagina_inicial, .x$url_doc, diretorio)


},NULL))

}


Expand All @@ -71,30 +70,31 @@ tjsp_baixar_cpopg_docs_cd_processo <- function(df,diretorio = "."){
#'
#' @return pdfs
#'
tjsp_baixar_docs_cd_processo <- function(cd_processo = NULL,
id_doc = NULL,
pagina_inicial = NULL,
urls = NULL,
diretorio = NULL){



tjsp_baixar_docs_cd_processo1 <- function(cd_processo = NULL,
id_doc = NULL,
pagina_inicial = NULL,
urls = NULL,
diretorio = NULL){
id <- stringr::str_c(cd_processo,
"_id_doc_",id_doc,
"_pagina_inicial_",pagina_inicial
)

pb <- progress::progress_bar$new(total = length(cd_processo))


purrr::walk2(urls,id,purrr::possibly(~{

pb$tick()

arquivo <- file.path(diretorio,paste0(.y,".pdf"))

httr::GET(.x,httr::write_disk(arquivo,overwrite = TRUE))

},NULL))

}

0 comments on commit 30ebc06

Please sign in to comment.