Get links from a URL


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

Only works on valid XML (ie. XHTML, but not HTML). Grabs an alphabetized list of links from the given URL.


Copy this code and paste it in your HTML
  1. %w[uri net/http rexml/document].each{|l|require l};(REXML::Document.new(Net::HTTP.get_response(URI.parse(ARGV[0])).read_body)).elements.each("//a/@href").collect{|l|l.to_s}.sort!.uniq!.each{|l|puts l}

Report this snippet


Comments


You need to login to view comments.