Skip to content

Instantly share code, notes, and snippets.

@jjesusfilho
Created May 7, 2017 22:56
Show Gist options
  • Save jjesusfilho/9c13204dc28a7d46b373f36fb38137e0 to your computer and use it in GitHub Desktop.
Save jjesusfilho/9c13204dc28a7d46b373f36fb38137e0 to your computer and use it in GitHub Desktop.
Dataprev - Acidentes de Trabalho
## 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"))
f<-xpathApply(s,"//table/*[@class='dl']/td/a/@href")
f<-unlist(f)
f<-str_extract(f,"htt.*")
f<-na.omit(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment