How does one parse html documents which make heavy use of javascript? I know there are a few libraries in python which can parse static xml/html files and I'm basically looking for a programme or library (or even firefox plugin) which reads html+javascript, executes the javascript bit and outputs html code without javascript so it would look identical if displayed in a browser.
As a simple example
<a href="javascript:web_link(34, true);">link</a>
should be replaced by the appropriate value the javascript function returns, e.g.
<a href="http://www.example.com">link</a>
A more complex example would be a saved facebook html page which is littered with loads of javascript code.
Probably related to How to "execute" HTML+Javascript page with Node.js but do I really need Node.js and JSDOM? Also slightly related is Python library for rendering HTML and javascript but I'm not interested in rendering just the pure html output.