From: Sita Rami Reddy Date: 2008-11-18T05:38:08+09:00 Subject: Re: How to extract links of a particular class type ------=_Part_34324_14021376.1226954498751 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanq very much peter..it surved my purpose On Mon, Nov 17, 2008 at 11:55 AM, Peter Szinek wrote: > require 'rubygems' > require 'scrubyt' > > google_data = Scrubyt::Extractor.define do > fetch 'http://www.google.com/search?hl=en&q=gap+inc' > > link_title "//a[@class='l']", :write_text => true do > link_url > end > next_page "Next", :limit => 3 > end > > output_file = open("google_results.txt", 'w') do |f| > google_data.to_hash.each do |result| > f.puts "#{result[:link_title]} - #{result[:link_url]}" > end > end > > produces: > > Shop clothes for women, men, maternity, baby, and kids at gap.com ... - > http://www.gap.com/ > Gap Inc. - http://www.gapinc.com/ > Gap Inc. - Careers - http://www.gapinc.com/public/Careers/careers.shtml > The Gap Inc. News - The New York Times - > http://topics.nytimes.com/top/news/business/companies/gap_the_inc/index.html > Gap (clothing retailer) - Wikipedia, the free encyclopedia - > http://en.wikipedia.org/wiki/Gap_(clothing) > GPS: Summary for GAP INC - Yahoo! Finance - > http://finance.yahoo.com/q?s=gps > GPS - BloggingStocks - http://gps.bloggingstocks.com/ > .... > .... > > > > > HTH, > Peter > ___ > http://www.rubyrailways.com > http://scrubyt.org > -- Sita Rami Reddy P ------=_Part_34324_14021376.1226954498751--