You can try HTMLDOC (<a href="http://htmldoc.rubyforge.org/" rel="nofollow">http://htmldoc.rubyforge.org/</a>) which is a wrapper around a C library (I believe) that does exactly this. I've used it before, it's pretty fast and stable and you don't have to worry about JVM.