雖然武林網www.vevb.com以前發布過相關的程式碼,但一些特別的網站不是很完美,最近幫客戶修改系統發現了這段程式碼,發現還不錯,特提取出來,方便大家使用。複製代碼代碼如下:
<%
webfolder=/
host=index_cn.asp'前台動態位址
folder=/'資料夾
filename=index_cn.html'產生靜態檔名
Fso_info host,folder,filename
response.write產生網站中文首頁靜態HTML完成.<br />
'產生html
Function Fso_info(host,folder,filename)
host=http://+Request.ServerVariables(HTTP_HOST)&webfolder&host
if SaveFile(&folder&filename&,&host&) then
response.Write &folder&filename& 產生成功. <br />
else
Response.write &folder&filename& 產生<font color='#FF0000'>失敗</font>,可能您的檔案名稱含有特殊字元.<br />
end if
End Function
'生成文件
function SaveFile(LocalFileName,RemoteFileUrl)
Dim Ads, Retrieval, GetRemoteData
On Error Resume Next
Set Retrieval = Server.CreateObject(Microso & ft.XM & LHTTP) '//把字拆開防止防毒軟體誤殺
With Retrieval
.Open Get, RemoteFileUrl, False, ,
.Send
GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
Set Ads = Server.CreateObject(Ado & db.Str & eam) '//將單字拆開防止防毒軟體誤殺
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile Server.MapPath(LocalFileName), 2
.Cancel()
.Close()
End With
Set Ads=nothing
if err <> 0 then
SaveFile = false
err.clear
else
SaveFile = true
end if
End function
%>