From: Jun Young Kim Date: 2009-01-12T09:15:09+09:00 Subject: Re: Help with HTML parsing you can also use ruby library Sanitize (http://wonko.com/post/sanitize) This library can make you parse html template very easily. let's see the following examples. Using Sanitize is easy. First, install it: sudo gem install sanitize Then call it like so: require 'rubygems' require 'sanitize' html = 'foo' Sanitize.clean(html) # => 'foo' By default, Sanitize removes all HTML. You can use one of the built-in configs to tell Sanitize to allow certain attributes and elements: Sanitize.clean(html, Sanitize::Config::RESTRICTED) # => 'foo' Sanitize.clean(html, Sanitize::Config::BASIC) # => 'foo' Sanitize.clean(html, Sanitize::Config::RELAXED) # => 'foo' Or, if you¡¯d like more control over what¡¯s allowed, you can provide your own custom configuration: Sanitize.clean(html, :elements => ['a', 'span'], :attributes => {'a' => ['href', 'title'], 'span' => ['class']}, :protocols => {'a' => {'href' => ['http', 'https', 'mailto']}}) good one :) 2009. 01. 02, ¿ÀÀü 6:42, Vivek Netha ÀÛ¼º: > Hello, > > I'm new to Watir\Ruby and need to resolve something that involves HTML > parsing - you could also call it screen scraping. I haven't used > either > library before, but I wanted to know if it is better to use Hpricot or > open_uri. The problem is similar to below: > > let's say I'm searching Google for some string, "Dungeons & Dragons" > for > instance. I want to parse through the first results page and get the > title text and url for the top 5 results. How would I do this using > Hpricot or open_uri or both? > > Please help! > > > Viv. > -- > Posted via http://www.ruby-forum.com/. > >