Created
July 5, 2017 02:22
-
-
Save anonymous/f63864f0f6224daa8fb836793cadbace 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
require 'open-uri' | |
require 'nokogiri' | |
servidores = [] | |
servidores_sem_salário = [] | |
(1..5).each do |page| | |
url = "http://www.portaltransparencia.gov.br/servidores/OrgaoExercicio-ListaServidores.asp?CodOrg=25201&Pagina=#{page}" | |
raw_html = open(url).read | |
html = Nokogiri::HTML(raw_html) | |
html.search("#listagem table td:nth-child(2) a").each do |servidor| | |
name = servidor.text.strip | |
path = servidor.attr("href") | |
url = "http://www.portaltransparencia.gov.br/servidores/#{path}" | |
raw_html = open(url).read | |
html = Nokogiri::HTML(raw_html) | |
link_da_remuneracao = html.search("#resumo a")[0] | |
path = link_da_remuneracao.attr("href") | |
url = "http://www.portaltransparencia.gov.br#{path}" | |
raw_html = open(url).read | |
html = Nokogiri::HTML(raw_html) | |
salário = html.search(".remuneracaolinhatotalliquida .colunaValor")[0] | |
print "=" | |
if salário | |
servidores << { name: name, salary: salário.text } | |
else | |
servidores_sem_salário << name | |
end | |
end | |
end | |
puts | |
puts "Servidores:" | |
servidores.each do |servidor| | |
puts "#{servidor[:name]} - #{servidor[:salary]}" | |
end | |
puts | |
puts "Servidores sem salário:" | |
puts servidores_sem_salário |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment