This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ## Acidentes de trabalho | |
| library(tidyverse) | |
| library(jsonlite) | |
| url<-"http://dadosabertos.dataprev.gov.br/opendata/act10/formato=json" | |
| a<-readLines(file(url, encoding="ISO-8859-1"), warn=FALSE) | |
| b<-fromJSON(a) | |
| c<-b$nodes$node | |
| c<-c[str_which(c$CNAE,"^(20|21)"),] | |
| c[]<-lapply(c,function(x) iconv(x,from="latin2",to="UTF-8")) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | library(httr) | |
| library(stringr) | |
| library(purrr) | |
| library(magrittr) | |
| library(ggmap) | |
| via_cep<-function(cep,latlong=TRUE){ | |
| cep %<>%stringr::str_replace("\\D","") %>% | |
| stringr::str_pad(8,side="left",pad="0") %>% | |
| as.character() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | cnpj<-function(cnpj){ | |
| cnpj<-str_replace_all(cnpj,"\\D+","") | |
| cnpj<-str_trim(cnpj) | |
| cnpj<-str_pad(cnpj,8,"left",0) | |
| df <- as.data.frame(setNames(replicate(30,numeric(0), simplify = F), | |
| c("atividade_principal.text","atividade_principal.code","data_situacao","nome","uf","telefone","email","atividades_secundarias.text1","atividades_secundarias.text2","atividades_secundarias.code1","atividades_secundarias.code2","situacao","bairro","logradouro","numero","cep","municipio","abertura","natureza_juridica","fantasia","cnpj","ultima_atualizacao","status","tipo","complemento","efr","motivo_situacao","situacao_especial","data_situacao_especial","capital_social"))) | |
| for (i in seq(cnpj)){ | |
| tryCatch({ | |
| d<-paste0("http://receitaws.com.br/v1/cnpj/",cnpj[i]) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ## Acesso a todos os BOs: | |
| # https://boletins.sesp.es.gov.br/ | |
| ## Exemplo | |
| library(httr) | |
| library(textreadr) | |
| library(stringi) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | library(httr) | |
| library(xml2) | |
| library(stringr) | |
| TRT4_meta<-function(livre="",quote=T,inicio="",fim=""){ | |
| if(quote==TRUE){livre<-deparse(livre)} | |
| url1<-"http://www.trt4.jus.br/portal/portal/trt4/consultas/jurisprudencia/acordaos" | |
| handle(url1) | |
| url2<-"http://gsa5.trt4.jus.br/search?" | |
| l<-list(client = "jurisp", | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ## Essas bibliotecas não precisam ser carregadas, mas devem estar instaladas. | |
| library(purrr) | |
| library(httr) | |
| library(boilerpipeR) | |
| trt4_inteiro_teor<-function(url){ | |
| url %>% purrr::map_chr(function(x){ | |
| x %>% | |
| httr::GET() %>% | |
| httr::content("text") %>% | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | library(stringr) | |
| library(magritr) | |
| query_extract<-function(string){ | |
| s<-str_split(string,"&") %>% | |
| unlist() | |
| nomes<-s %>% | |
| str_extract(".*?(?=\\=)") | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | library(httr) | |
| library(xml2) | |
| library(stringr) | |
| library(purrr) | |
| library(tibble) | |
| ## Há duas opções: usar uma palavra ou uma frase. | |
| tjscSG<- function(palavra="",frase=""){ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | library(httr) | |
| library(xml2) | |
| library(stringr) | |
| library(boilerpipeR) | |
| tjrsSG_meta<-function(BuscaLivre="",quote=TRUE){ | |
| if(quote==TRUE) BuscaLivre<-deparse(BuscaLivre) | |
| url<-"http://www.tjrs.jus.br/busca/search?" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ifs<-function(x,y,z=NULL){ | |
| stopifnot(is.list(y)) | |
| #if(length(z)==0) {z<-x} | |
| for(i in 1:length(y)){ | |
| x<-ifelse(stringr::str_detect(x,y[[i]][1]),y[[i]][2],x) | |
| } | |
| return(x) | |
| } |