From: Peter Szinek Date: 2007-11-26T20:48:11+09:00 Subject: Re: Easy way for a Nuub to get link-element from a html-source Marcus Strube wrote: > hi all. > > im very new to ruby and im not sure how to do this the easiest way in > ruby. i want to read the content from e.g. "www.spiegel.de" and just > this line > > > > and from this line the "title" and the "href" > > since the order in "link" is not sure, it doesnt look like regexp is the > first choice. and i couldn't find a HTML::Parse. Another possibility is scRUBYt!: ========================================== require 'rubygems' require 'scrubyt' feed_data = Scrubyt::Extractor.define do fetch 'http://www.spiegel.de/' link "//link[@rel='alternate']" do title "title", :type => :attribute href "href", :type => :attribute end end puts feed_data.to_xml ========================================== output: ========================================== SPIEGEL ONLINE als RSS-Feed http://www.spiegel.de/schlagzeilen/rss/index.xml ========================================== or, to_hash: ========================================== [{:title=>"SPIEGEL ONLINE als RSS-Feed", :href=>"http://www.spiegel.de/schlagzeilen/rss/index.xml"}] ========================================== Cheers, Peter ___ http://www.rubyrailways.com http://scrubyt.org