Last active
February 1, 2024 12:36
-
-
Save jjesusfilho/b7230a7b4cc74d51a132a8fa6f6bc2c3 to your computer and use it in GitHub Desktop.
This file contains 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
ibge_ftp <- paste0("https://ftp.ibge.gov.br/Trabalho_e_Rendimento/", | |
"Pesquisa_Nacional_por_Amostra_de_Domicilios_anual/", | |
"microdados/") | |
r1 <- ibge_ftp |> | |
httr2::request() |> | |
httr2::req_perform() |> | |
httr2::resp_body_html() | |
diretorio <- r1 |> | |
xml2::xml_find_all("//td/a") |> | |
xml2::xml_attr("href") |> | |
tail(-1) | |
data <- r1 |> | |
xml2::xml_find_all("//td[a/@href]/following-sibling::td[1][@align='right']") |> | |
xml2::xml_text() | |
url2 <- "https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_anual/microdados/2015/" | |
zips <- url2 |> | |
httr2::request() |> | |
httr2::req_perform() |> | |
httr2::resp_body_html() |> | |
xml2::xml_find_all("//a[contains(@href,'zip')]") |> | |
xml2::xml_attr('href') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment