生成静态页面关键技术
<%
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
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
'////////////////////////////////////////////
sub refresh_news(id)
set rs=server.createobject("adodb.recordset")
sql="select * from Conews where id="&id&" "
rs.open sql,conn,1,1
if rs.eof then
response.write "<SCRIPT language=JavaScript>alert('参数出错!');"
response.write "window.close();</SCRIPT>"
response.end
else
weburl ="http://" & Request.ServerVariables("HTTP_HOST")
file_name=rs("id")
FromPage = weburl&"/news_info.asp?id="&id&""
FileName = "../news_detail/"&file_name&".html"
sText = GetHTTPPage(FromPage)
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set OpenFile = FileObject.OpenTextFile(Server.MapPath(FileName),2,True)
openFile.writeline(sText)
Set OpenFile = Nothing
end if
rs.close
set rs=nothing
end sub
sub refresh_product(id)
set rs=server.createobject("adodb.recordset")
sql="select * from product where id="&id&" "
rs.open sql,conn,1,1
if rs.eof then
response.write "<SCRIPT language=JavaScript>alert('参数出错!');"
response.write "window.close();</SCRIPT>"
response.end
else
weburl ="http://" & Request.ServerVariables("HTTP_HOST")
file_name=rs("id")
FromPage = weburl&"/product_info.asp?id="&request("id")&""
FileName = "../product/"&file_name&".html"
sText = GetHTTPPage(FromPage)
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set OpenFile = FileObject.OpenTextFile(Server.MapPath(FileName),2,True)
openFile.writeline(sText)
FromPage = weburl&"/en/product_info.asp?id="&request("id")&""
FileName = "../en/product/"&file_name&".html"
sText = GetHTTPPage(FromPage)
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set OpenFile = FileObject.OpenTextFile(Server.MapPath(FileName),2,True)
openFile.writeline(sText)
Set OpenFile = Nothing
Set OpenFile = Nothing
end if
rs.close
set rs=nothing
end sub
sub refresh_productlist2(sid)
set rs=server.createobject("adodb.recordset")
sql="select * from mm_product_smallclass where id="&sid&" "
rs.open sql,conn,1,1
if rs.eof then
response.write "<SCRIPT language=JavaScript>alert('参数出错!');"
response.write "window.close();</SCRIPT>"
response.end
else
weburl ="http://" & Request.ServerVariables("HTTP_HOST")
file_name=rs("id")
FromPage = weburl&"/product/index.asp?sid="&rs("id")&""
FileName = "../product/list2_"&rs("id")&".html"
sText = GetHTTPPage(FromPage)
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set OpenFile = FileObject.OpenTextFile(Server.MapPath(FileName),2,True)
openFile.writeline(sText)
Set OpenFile = Nothing
end if
rs.close
set rs=nothing
end sub
sub refresh_case(id)
set rs=server.createobject("adodb.recordset")
sql="select * from project where id="&id&" "
rs.open sql,conn,1,1
if rs.eof then
response.write "<SCRIPT language=JavaScript>alert('参数出错!');"
response.write "window.close();</SCRIPT>"
response.end
else
weburl ="http://" & Request.ServerVariables("HTTP_HOST")
file_name=rs("id")
FromPage = weburl&"/case_info.asp?id="&request("id")&""
FileName = "../case/"&file_name&".html"
sText = GetHTTPPage(FromPage)
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
Set OpenFile = FileObject.OpenTextFile(Server.MapPath(FileName),2,True)
openFile.writeline(sText)
Set OpenFile = Nothing
end if
rs.close
set rs=nothing
end sub
%>