执行JavaScript为服务器端缓存渲染HTML [英] Executing JavaScript to Render HTML for Server-Side Caching
问题描述
有很多网站提供的小部件,这些小部件通过 DOM 操作或 document.write()
生成HTML。我不希望通过额外的请求来减慢浏览器的运行速度,并且信任另一个提供者快速,可靠并且不会更改窗口小部件输出,我希望执行* JavaScript来生成呈现的HTML,然后保存该HTML源代码。 p>
我看过的东西似乎不可行或太难:
- 链接浏览器( not lynx!)
- 无头无际地使用Xvfb加Firefox和Greasemonkey( )
- 全部Java浏览器工具包眼镜蛇(最好的选择!)
有什么想法?
**显然你不能完全执行JavaScript,因为它不一定有退出路径,但你明白了。
维基百科的 服务器端JavaScript文章列出了许多实现,其中许多实现基于Mozilla的 Rhino JavaScript到Java转换器或其表兄 SpiderMonkey 引擎可以在Firefox和其他基于Gecko的浏览器中找到)。特别是,像 mod_js 这样简单的Apache可能适合您的需求。
There are lots of widgets provided by sites that are effectively bits of JavaScript that generate HTML through DOM manipulation or document.write()
. 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.
Things I've looked into that seem unworkable or way too difficult:
- The Links Browser (not lynx!)
- Headless use of Xvfb plus Firefox plus Greasemonkey (yikes)
- The all-Java browser toolkit Cobra (the best bet!)
Any ideas?
** Obviously you can't really execute the JavaScript completely, as it doesn't necessarily have an exit path, but you get the idea.
Wikipedia's "Server-side JavaScript" article lists numerous implementations, many of which are based on Mozilla's Rhino JavaScript-to-Java converter, or its cousin SpiderMonkey (the same engine as found in Firefox and other Gecko-based browsers). In particular, something simple like mod_js for Apache may suit your needs.
这篇关于执行JavaScript为服务器端缓存渲染HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!