Posted By

burke on 08/03/07


Tagged

xhtml oneliner


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Get links from a URL


 / Published in: Ruby
 

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

  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  

You need to login to post a comment.