ASP批量生成静态HTML的实例程序,可以批量生成,也可以批量删除,页面没有怎么美化,关键是想实现ASP生成静态的功能。生成HTML速度很快
Dim StarTime
Dim cnt:cnt = 1
StarTime = Timer()
start = request("start") '获取本轮指针的开始位置
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" '要生成的文件路径及地址
UrlPath ="http://www.021jz.com.cn/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 '通过刷新的方式进行下一轮请求,并将指针变量start传递到下一轮
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('批量生成成功,所需时间:"&sj&" 秒');" & Chr(13)
response.write "window.document.location.href='index.asp?page="&pg&"';"&Chr(13)
response.write "</script>" & Chr(13)
Response.End
end if