
引用内容
<%
'==================================================
'HTML采集信息函数
'==================================================
On Error Resume Next '忽略掉所有非致命性错误
Server.Scripttimeout=999 '设置运行超时
Function Gethttppage(Path)
T = Getbody(Path)
Gethttppage=Bytestobstr(T,"Gb2312")
End Function
Function Getbody(Url) '然后调用xmlhttp组件创建一个对象并进行初始化设置。
On Error Resume Next
Set Retrieval = Createobject("Microsoft.Xmlhttp")
Retrieval.Open "Get", Url, False, "", ""
Retrieval.Send
Getbody = Retrieval.Responsebody
Set Retrieval = Nothing
End Function
Function BytesToBstr(body,Cset) '默认的utf-8编码转换成gb2312编码
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 = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
pageurl="http://www.tc711.com/2006" '这个自己修改即可
url=pageurl &"/index.asp" '动态页地址
pageurls="index.html" '生成的静态页地址
pageurlss=server.MapPath(pageurls)
set fso= Server.CreateObject("Scripting.FileSystemObject")
set pagefile=fso.CreateTextFile(pageurlss,true)
page=Gethttppage(url)
'response.Write page
pagefile.WriteLine page
pagefile.close
response.Write("----生成成功!!<a href="&pageurls&">返回查看</a>")
%>

引用内容
现在到处都流行动态网站页面生成静态页,总的说我不是很赞同,认为有误导初学者之嫌,可我也不是圣人用户有要求,自然也不能免俗。
我这里提供一个简单的不用模板可以直接生成HTML静态页的方法.
如一个正常的index.asp动态页面,
新建一个文件 makeasp2html.asp
<!--#include file="index.asp"-->
<%
If request.Form("asp2html")"" then
filename="index.html"
set fso = Server.CreateObject("Scripting.FileSystemObject")
set fout = fso.CreateTextFile(server.mappath(""&filename&""))
fout.write request.form("asp2html")
fout.close
set fout=nothing
set fso=nothing
end if
%>
这样index.html文件就生成了,连模板都用不着,只要服务器要支持FSO,将正常情况下使用的ASP文件读取到textarea里就可以了。