Last active
December 18, 2015 04:19
-
-
Save rafapolo/5724494 to your computer and use it in GitHub Desktop.
lista nome, atividade e data de "morto ou desaparecido" de centenas de desaparecidos em http://www.desaparecidospoliticos.org.br
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
require 'rubygems' | |
require 'sanitize' | |
require 'mechanize' | |
URL = "http://www.desaparecidospoliticos.org.br" | |
browser = Mechanize.new | |
browser.user_agent_alias = 'Mac Safari' | |
puts "Listando..." | |
browser.get("#{URL}/pessoas.php?m=3") do |lista| | |
lista.search('//a[starts-with(@href, "pessoa.php?id=")]').each do |link| | |
nome = link.text | |
atividade = "" | |
morto = "" | |
browser.get("#{URL}/#{link.values.first}") do |pessoa| | |
el = pessoa.at("strong[text()='Atividade:']") | |
atividade = el.parent.parent.at("td[2]").text if el | |
morto = Sanitize.clean(pessoa.at('table.tb_nomes/tr/td/div.margin_5').parent.parent.search("td[2]").first.children.to_s.encode("utf-8")).gsub(/\s+/, " ").strip | |
end | |
puts nome | |
puts atividade unless atividade.empty? | |
puts morto | |
puts | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment