Load Simple Pag Nokogiri


/ Published in: Ruby
Save to your folder(s)

Ejemplo de Carga de Página con Nokogiri


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.