Created
October 17, 2008 12:37
-
-
Save bastos/17403 to your computer and use it in GitHub Desktop.
Busca de anúncios no diário do nordeste
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
require 'cgi' | |
cgi = CGI.new() # New CGI object | |
puts "Content-type: text/html\n\n" | |
puts "<h1>Procurando por #{cgi.params['q']}</h1>" | |
doc = Hpricot(open("http://diariodonordeste.globo.com/classif/consultando.asp?Filtro=#{cgi.params['q']}&Operador=OU&Filtro2=")) | |
doc.search(".anuncio").each do | anuncio | | |
puts '<div style="margin-top:10px;border-top:1px solid #333;padding:5px;">' | |
puts '<p>' | |
puts anuncio.inner_text.strip | |
puts '</p><p>Telefone:<br />' | |
puts anuncio.inner_text.scan(/[0-9]{4}+\.[0-9]{4}+/).join(', ') | |
puts '</p></div>' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment