ASP生成静态网页之自动按模板生成网站首页

发布时间:2010年03月18日      浏览次数:770 次
<%
Response.Expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
Response.Buffer = True
Response.Clear
Server.ScriptTimeOut=999999999
on error resume next
'***************************************************************
'* 定义 从模板从读取首页 函数
'* 说明:模板文件名为:index_Template.asp
'***************************************************************
Function GetPage(url)
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False, "", ""
.Send
GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
'***************************************************************
'* 生页首页,文件名为:default.htm
'***************************************************************
dim Tstr
Tstr = GetPage("http://www.abc.net/index_Template.asp")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(Server.MapPath(".")&"/default.htm")
fout.Write Tstr
fout.close
Response.write"<script>alert(""生成首页成功!\n\n文件名为:default.htm"");location.href="http://www.abc.net";</script>"
Response.end
%>
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!