使用javascript编译html并将其转储到文件中

compile html with javascript and dump it to file

本文关键字:转储 文件 javascript 编译 html 使用      更新时间:2023-09-26

我有一个带有javascript代码的html,它可以修改html并打印数据,我想把这个页面转储到一个文件中。

<html>
<head>
<script type="text/javascript">
document.write("<h1>This is a heading one </h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>
</head>
<body>
<h1>This is a heading two </h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>

output.html

<html>
<head>
<script type="text/javascript">
document.write("<h1>This is a heading one </h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>
</head>
<body>
<h1>This is a heading one </h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<h1>This is a heading two </h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>

我想我需要一些类似html+java脚本引擎的东西。。带有命令行界面的浏览器,这样我就可以调用页面,然后将其输出转储到文件中。。有什么想法吗??。。。感谢

如果你只想手动做几次,你可以使用IE 9开发工具。在IE 9中,可以执行F12,然后按Ctrl+S将文件保存到所需位置。