asp生成静态页面问题,未经解析执行,就直接输出,高手快帮我看看,在线给分!!!
Kabin 2006-09-12 03:41:25 网上找到一段代码,生成静态页面用,
运行了下,的确生成htm文件,
但是,所有生成的文件都是未解析执行的asp源码文件,
只是换了个扩展名保存而已,高手请看看哪里出了问题,thanks!
<%
'1、输入url目标网页地址,返回值getHTTPPage是目标网页的html代码
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
'2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
Function BytesToBstr(body,Cset)
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
%>
<%
aspFileName =request("aspFileName")
htmlFileName =request.form("htmlFileName")
bCreateHtml = false
if htmlFileName <> "" and aspFileName <> "" then
set fso=CreateObject("Scripting.FileSystemObject")
set f=fso.CreateTextFile( server.mappath( htmlFileName ), true )
f.WriteLine( getHTTPPage(server.MapPath(aspFileName)) )
f.close
set f = nothing
set fso = nothing
end if
%>