When I run my script with:
$ ruby htmlImg.rb https://ejemplo.com/index.html
I get this error:
/usr/share/ruby/2.3.0/net/http.rb:479:in 'get_response': undefined method 'hostname' for "https://twitter.com/Yojiexo":String (NoMethodError)
from /usr/share/ruby/2.3.0/net/http.rb:456:in 'get'
from htmlImg.rb:4:in '<main>'
This the code:
require 'nokogiri'
require 'net/http'
pagina = Net::HTTP.get(ARGV[0],ARGV[1])
enlace = Nokogiri::HTML(pagina).xpath('//pag[@href]').map {|link| link['href']}
imagen = Nokogiri::HTML(pagina).xpath('//img[@src]').map {|link| link ['src']}
puts "Los enlaces son: " + enlace
puts "Las direcciones de imagenes son: " + imagen