<p>There are lots of widgets provided by sites that are effectively bits of JavaScript that generate HTML through <em>DOM</em> manipulation or <code>document.write()</code>. Rather than slow the browser down even more with additional requests and trust yet another provider to be fast, reliable and not change the widget output, I want to execute* the JavaScript to generate the rendered HTML, and then save that HTML source.­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>

<p>Things I've looked into that seem unworkable or way too difficult:</p>

<ol>
<li>The Links Browser (<em>not lynx!</em>)</li>
<li>Headless use of Xvfb plus Firefox plus Greasemonkey (<em>yikes</em>)</li>
<li>The all-Java browser toolkit Cobra (<em>the best bet!</em>) </li>
</ol>

<p>Any ideas? </p>

<p>** Obviously you can't really execute the JavaScript completely, as it doesn't necessarily have an exit path, but you get the idea.</p>

[{'answer_id': 15037, 'author': 'Sören Kuklau', 'author_id': 1600, 'author_profile': 'https://Stackoverflow.com/users/1600', 'pm_score': 3, 'selected': True, 'text': '<p>Wikipedia\'s <a href="http://en.wikipedia.org/wiki/Server-side_JavaScript" rel="nofollow noreferrer">"Server-side JavaScript"</a> article lists numerous implementations, many of which are based on Mozilla\'s <strong>Rhino</strong> JavaScript-to-Java converter, or its cousin <strong>SpiderMonkey</strong> (the same engine as found in Firefox and other Gecko-based browsers). In particular, something simple like <a href="http://www.modjs.org/" rel="nofollow noreferrer"><strong>mod_js</strong></a> for Apache may suit your needs.</p>\n'}, {'answer_id': 15041, 'author': 'Jon Bright', 'author_id': 1813, 'author_profile': 'https://Stackoverflow.com/users/1813', 'pm_score': 2, 'selected': False, 'text': '<p>If you\'re just using plain JS, <a href="http://www.mozilla.org/rhino/" rel="nofollow noreferrer">Rhino</a> should do the trick.  But if the JS code is actually calling DOM methods and so on, you\'re going to need a full-blown browser. <a href="http://simile.mit.edu/wiki/Crowbar" rel="nofollow noreferrer">Crowbar</a> might help you.</p>\n\n<p>Is this really going to make things faster for users without causing compatibility issues?</p>\n'}, {'answer_id': 27782, 'author': 'Sam Hasler', 'author_id': 2541, 'author_profile': 'https://Stackoverflow.com/users/2541', 'pm_score': 2, 'selected': False, 'text': '<p>There\'s John Resig\'s project <a href="http://ejohn.org/blog/bringing-the-browser-to-the-server/" rel="nofollow noreferrer">Bringing the Browser to the Server</a>: "browser/DOM environment, written in JavaScript, that runs on top of <a href="http://www.mozilla.org/rhino/" rel="nofollow noreferrer">Rhino</a>; capable of running jQuery, Prototype, and MochiKit (at the very least)."</p>\n'}]
['https://Stackoverflow.com/questions/15007', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']