ASP批量转换HTML

作者在 2007-07-02 23:31:00 发布以下内容

ASP转换成HTML,为了网站安全,访问速度快,现在很多网站都将ASP,JSP,.NET都转换成HTML格式,在网上找了很多转换方法,如果有固定格式的页面就最好用模板的方法,如果全是动态页面,从数据库读出,用下面的方法我个人觉得很适用,我把我使用的方法帖跟大家分享.

<!--#include file="conn.asp" -->
<%
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
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
Dim weburl
sql = "SELECT * FROM exscore  order by userid desc"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.OPEN sql,conn,3,2
do while not rs.eof
weburl="http://"&Request.ServerVariables("SERVER_NAME")&"/view.asp?xh="&rs("userid")&""
stext=getHTTPPage(weburl)

Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
File=Server.MapPath("html/"&rs("userid")&".htm")
'response.write weburl
'response.end
Set openFile=FileObject.OpenTextfile(file,8,true)
openFile.writeline(stext) 
Set OpenFile=nothing 
rs.movenext
loop
rs.close
set rs=nothing
%>

编程技术 | 阅读 3679 次
文章评论,共0条
游客请输入验证码
浏览48469次