ASP生成静态网页方法

  • 内容
  • 评论
  • 相关

比如将details.asp?id=i(i为1到3)转化成静态网页index1.htm,index2.htm,index3.htm

----------------------------------------

<%
dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp
Html_Temp="<ul>"
For i=1 To 3
Html_Temp = Html_Temp&"<li>"
Item_Classid = i
FileName = "Index"&Item_Classid&".htm"
FilePath = Server.MapPath("/")&"\"&FileName
Html_Temp = Html_Temp&FilePath&"</li>"
Do_Url = "http://"
Do_Url = Do_Url&Request.Servervariables("SERVER_NAME")&"/details.asp"
Do_Url = Do_Url&"?id="&Item_Classid
strUrl = Do_Url
dim objXmlHttp
set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET",strUrl,false
objXmlHttp.send()
Dim binFileData
binFileData = objXmlHttp.responseBody
Dim objAdoStream
set objAdoStream = Server.CreateObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2
objAdoStream.Close()
Next
Html_Temp = Html_Temp&"<ul>"
%>
<%
Response.Write ( "成功生成文件:" )
Response.Write ( "<br>" )
Response.Write Html_Temp
%>

评论

0条评论

    发表评论

    电子邮件地址不会被公开。 必填项已用*标注

    click to change 看不清?点击换一张!