Extracting a part of a web page

I am making a campaign site for a client. On the site he want me to
reuse parts of exsisting webpages from his corporate site.
What I want to do is to extract a certain part from exsisting web page
and then inject that into my own template and serv it.
The content that I need to extract is inside a a named div, i.e.
everything inside
<div id=maincontentBox"> and the closing </div>.

Can anyone give me some pointers in the right direction?

/Jonas

I am making a campaign site for a client. On the site he want me to
reuse parts of exsisting webpages from his corporate site.
What I want to do is to extract a certain part from exsisting web page
and then inject that into my own template and serv it.
The content that I need to extract is inside a a named div, i.e.
everything inside
<div id=maincontentBox"> and the closing </div>.

Can anyone give me some pointers in the right direction?

# gem install hpricot --source code.whytheluckystiff.net

require 'rubygems'
require 'hpricot'
doc = Hpricot.parse(File.read("index.html"))
doc.at("div#maincontentBox").inner_html

More information and examples are at: http://code.whytheluckystiff.net/hpricot/

/Jonas

Sincerely,

Tom Lieber
http://AllTom.com/
http://GadgetLife.org/