Skip to content

Instantly share code, notes, and snippets.

@leobarone
Created April 26, 2017 13:02
Show Gist options
  • Save leobarone/c4e17abf11318c49e2b69325990c74f4 to your computer and use it in GitHub Desktop.
Save leobarone/c4e17abf11318c49e2b69325990c74f4 to your computer and use it in GitHub Desktop.
library(rvest)
library(purrr)
stf_incidente <- function(tipo, numero){
stf_session <- html_session("http://www.stf.jus.br/portal/processo/listarProcesso.asp")
stf_session$url <- "http://www.stf.jus.br/portal/processo/listarProcesso.asp"
stf_form <- html_form(read_html(stf_session))[[3]]
stf_form <- set_values(stf_form,
numero = numero)
stf_submission <- submit_form(stf_session, stf_form)
processos <- stf_submission %>%
html_nodes("td a") %>%
html_text()
incidentes <- stf_submission %>%
html_nodes("td a") %>%
html_attr("href")
incidentes <- as.numeric(
substr(incidentes, 43, nchar(incidentes))
)
incidentes[grep(tipo, processos)]
}
stf_incidente("ADI", 3000)
map_dbl(1:100, function(x) {stf_incidente("ADI", x)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment