asp定时生成html

我用这个是为了生成首页

 我这里用了一个txt文本储存时间

 

 

 

 

<%  
set fs=server.createobject("scripting.filesystemobject")
file
=server.mappath("time.txt")
set txt=fs.opentextfile(file,1,true)
if not txt.atendofstream then
times
=txt.ReadLine
Else 
response.write 
"<br /><!--有没有发现time.txt 开始生成!-->"
HtmlPage 
= "time.txt" '//生成的HTML文件名 
Template = NOW()
Set FSO = Server.CreateObject ("Scripting.FileSystemObject"
Set FileOut = FSO.CreateTextFile(Server.MapPath (HtmlPage)) 
FileOut.WriteLine Template 
FileOut.Close 
Set FSO = Nothing 

end If


If datediff("s",times,NOW()) > 3600 Then    '//上次更新到现在的时间 大于 3600秒 则 更新
response.write "<br /><!--时间过了开始更新-->"

code 
= "这里是需要生成的html代码"   '//如何得到代码的方式有很多

'//用FSO生成HTML页面 
HtmlPage = "index.html" '//生成的HTML文件名 
Template = code
Set FSO = Server.CreateObject ("Scripting.FileSystemObject"
Set FileOut = FSO.CreateTextFile(Server.MapPath (HtmlPage)) 
FileOut.WriteLine Template 
FileOut.Close 
Set FSO = Nothing 

'//用FSO生成time.txt文件 
HtmlPage = "time.txt" '//生成的HTML文件名 
Template = NOW()
Set FSO = Server.CreateObject ("Scripting.FileSystemObject"
Set FileOut = FSO.CreateTextFile(Server.MapPath (HtmlPage)) 
FileOut.WriteLine Template 
FileOut.Close 
Set FSO = Nothing 

Else 

response.write 
"<br /><!-- 已经过去"&datediff("s",times,NOW())&"秒!-->"

End If
%>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值