您的位置 >>> 星想互联 >>>  >>> ASP
在线生成静态HTML程序
点击数:4146  发布时间2013-05-14 12:52:27

set conn= Server.CreateObject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("news.mdb")

set rs=conn.execute("select *  from news")


set fso=server.CreateObject("scripting.filesystemobject")
do while not rs.eof
path=year(rs("fdate"))&month(rs("fdate"))&day(rs("fdate"))
path=server.MapPath(path)
if not(fso.folderexists(path)) then '如果文件夹不存在就创建
fso.createfolder(path)
end if
rs.movenext
loop

path=server.MapPath("temp.html")
set textfile=fso.opentextfile(path,1,true)
con=textfile.readall

response.write con

rs.requery '重新查询数据库存

do while not rs.eof
path=year(rs("fdate"))&month(rs("fdate"))&day(rs("fdate"))&"/"&rs("title")&".html" '生成文件路径
path=server.mappath(path)
set ts=fso.createtextfile(path)
temp=con '模板替换
temp=replace(temp,"$title$",rs("title"))
temp=replace(temp,"$fdate$",rs("fdate"))
temp=replace(temp,"$content$",rs("content"))
ts.write temp
rs.movenext
loop

来源:星想互联
【上一篇】批量删除记录
【下一篇】批量删除