When surfing the net I found Hpricot for Ruby.This helps me in parsing the HTML pages.
To install ‘hpricot’ use gem installer..
In the command prompt type this to install ‘hpricot’
gem install hpricot
Then in your code include ‘hpricot’ using
require ‘hpricot’
require ‘open-uri’
@title = (Hpricot(open(url))/:title).inner_text
This code will help in fetching the title of the html pages.
The code under my prevoius post ‘Get the title of the given url using ruby’ can be replaced with this code. This reduces the number of lines of code.
I got this code from this link
The usage of Hpricot doesn’t stop with this. It is used in many cases, i will post usages of ‘hrpicot’ in future.

