Posted By

danielousky on 09/04/13


Tagged

load pag nokogiri


Versions (?)

Load Simple Pag Nokogiri


 / Published in: Ruby
 

Ejemplo de Carga de Página con Nokogiri

  1. def cargar_pag(enlace)
  2. require 'nokogiri'
  3. require "net/http"
  4. require "uri"
  5.  
  6. url = URI.parse(enlace)
  7. req = Net::HTTP::Post.new(url.path)
  8.  
  9. http = Net::HTTP.new(url.host, url.port)
  10. http.use_ssl = true
  11. http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  12. @return = http.request(req)
  13. resp = @return.body #.force_encoding("utf-8")
  14. # resp = resp.delete "&"
  15.  
  16. return Nokogiri::HTML(resp)
  17.  
  18. end

Report this snippet  

You need to login to post a comment.