Convert an ASP page into an HTM page

Source: Internet
Author: User
Page | conversion

Some time ago There is an ASP page to perform slowly, the number of visitors, and not often modified, and lazy directly into static, every time to download from the server to change, had to think of ways to convert the ASP page into the HTM static page ...

Have seen such an article before, but did not care too much, really want to use when it is difficult to find a suitable, so the online search for a long time to finally find the more appropriate code plus their own changes, as follows:

<%
Functiongetpage (URL)
' Get the contents of the file
Dimretrieval
Setretrieval=createobject ("Microsoft.XMLHTTP")
Withretrieval
. Open "Get", Url,false ', "", "" "
. Send
Getpage=bytestobstr (. Responsebody)
Endwith
Setretrieval=nothing
Endfunction

Functionbytestobstr (body)
Dimobjstream
Setobjstream=server.createobject ("ADODB.stream")
Objstream. Type=1
Objstream. Mode=3
Objstream. Open
Objstream. Writebody
Objstream. Position=0
Objstream. type=2
Objstream. charset= "GB2312"
Bytestobstr=objstream. ReadText
Objstream. Close
Setobjstream=nothing
Endfunction

Onerrorresumenext
Url= the address of the page to read
Response.Write "Start updating the home page ..."
Wstr=getpage (URL)

' Response.Write (WSTR)
Setfs=server.createobject ("Scripting.FileSystemObject")

' Ifnotmyfile.folderexists (server. MapPath ("/html/")) Then
' Myfile.createfolder (server. MapPath ("/html/")) '
' EndIf

' Address of the page to be stored
Dizhi=server. MapPath ("index.htm")
If (fs. FileExists (Dizhi)) Then
Fs. DeleteFile (Dizhi)
EndIf

Setcrfi=fs. CreateTextFile (Dizhi)
Crfi.writeline (WSTR)
Setcrfi=nothing
Setfs=nothing
Response.Write "...<fontcolor=red> Update complete!" </font> "
%>


Code is the simplest, directly saved into an ASP file can be, as long as the URL (to convert the ASP address) and Dizhi (to save the HTML address) set up on it, generally these two files in the same directory, in order to ensure that the picture or CSS, JS function.

Hope to be useful to those who are looking for asp->htm.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.