ASP批量生成靜态HTML的(de)實例程序,可(kě)以批量生成,也(yě)可(kě)以批量删除,頁面沒有怎麽美(měi)化(huà),關鍵是想實現ASP生成靜态的(de)功能。生成HTML速度很快(kuài)
Dim StarTime
Dim cnt:cnt = 1
StarTime = Timer()
start = request("start") '獲取本輪指針的(de)開始位置
If IsNumeric(start) Then start = CLng(start) Else start=1
If start=0 Then start = 1
set rs4=server.createobject("adodb.recordset")
sql="select * from gjc"
rs4.open sql,conn,1,1
rs4.AbsolutePosition = start
while not rs4.eof and cnt < 21
k=rs4("tags")
py=rs4("pinyin")
title=rs4("title")
Call CheckAndCreateFolder("/ganxi/"&py)
FileName="/ganxi/"&py&"/index.html" '要生成的(de)文件路徑及地址
UrlPath ="/2.asp?key="&k&"&t="&title&"&"
Call SaveToFile(FileName,GetTheHTMLCode(UrlPath))
cnt = cnt + 1
start = start + 1
rs4.movenext
wend
if not rs4.eof Then '通(tōng)過刷新的(de)方式進行下(xià)一輪請求,并将指針變量start傳遞到下(xià)一輪
response.write "<meta http-equiv='refresh' content='0;URL=?start="&start&"'>"
else
Dim EndTime
EndTime = Timer()
sj=FormatNumber((EndTime - StarTime) * 1000, 3)
sj=sj/1000
response.write "<script language='javascript'>" & chr(13)
response.write "alert('批量生成成功,所需時(shí)間:"&sj&" 秒');" & Chr(13)
response.write "window.document.location.href='index.asp?page="&pg&"';"&Chr(13)
response.write "</script>" & Chr(13)
Response.End
end if