<!--模块文件(template.htm)-->
<html>
<head>
<title>%title%</title>
</head>
<body>
%content%
</body>
</html> br />
<!--testtemplate.asp-->
<%
dim fso,f
dim strtitle,strcontent,strout
"创建文件系统对象
set fso=server.createobject("scripting.filesystemobject")
"打开网页模板文件,读取模板内容
set f=fso.opentextfile(server.mappath("template.htm"))
strout=f.readall
f.close
strtitle="这是生成的网页标题"
strcontent="这是生成的网页内容"
"用真实内容替换模板中的标记
strout=replace(strout,"%title%",strtitle)
strout=replace(strout,"%content%",strcontent)
"创建要生成的静态页
set f=fso.createtextfile(server.mappath("new.htm"),true)
"写入网页内容
f.writeline strout
f.close
response.write "生成静态页成功!"
"释放文件系统对象
set f=nothing
set fso=nothing
%>
fso批量生成html原理
最新推荐文章于 2024-09-26 08:58:28 发布