Need an HTML Dom parser - checkout this great little class.
A simple PHP HTML DOM parser written in PHP5+, supports invalid HTML, and provides a very easy way to handle HTML elements.
http://sourceforge.net/projects/simplehtmldom/
http://simplehtmldom.sourceforge.net/