將asp頁面轉換成htm頁面

來源:互聯網
上載者:User

【標題】將asp頁面轉換成htm頁面

【內容】
前段時間有個asp頁面執行起來很慢,訪問人數又頗多,而且又不經常修改,又懶得直接做成靜態,每次都要從伺服器下載來改,只好想辦法把asp頁面轉化成htm靜態頁面了。。。

以前就曾經看到這樣的文章,不過沒太在意,真正想用的時候很難找到一個合適的,於是在網上搜尋了半天終於找到比較合適的代碼再加上自己的修改,如下:

<%
Function GetPage(url)
'獲得檔案內容
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
   .Open "Get", url, False ', "", ""
   .Send
   GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function

Function BytesToBstr(body)
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 = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

on error resume next
Url="http://www.sina.com.cn"'要讀取的頁面地址
response.write "開始更新首頁..."
wstr = GetPage(Url)

'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")

'if not MyFile.FolderExists(server.MapPath("/html/")) then
'MyFile.CreateFolder(server.MapPath("/html/"))'
'end if

'要存放的頁面地址
dizhi=server.MapPath("index.htm")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If

Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
set CrFi=nothing
set fs=nothing
response.write "...<font color=red>更新完成!</font>"
%>

代碼算是最簡單的,直接儲存成一個asp檔案即可,只要把URL(要轉化的asp地址)和dizhi(要儲存的html地址)設定好就可以了,一般這兩個檔案在同一個目錄,才能保證圖片或者css、js起作用。

希望對那些正在尋找由asp產生htm的朋友有用。

【關鍵字】ASP頁面轉換成HTML頁面

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.