Ways to convert ASP Dynamic Web pages into HTM static pages

Source: Internet
Author: User
Dynamic | static | page | page |

Some time ago There is an ASP page to perform slowly, the number of visitors, but 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:

<%
Function getpage (URL)
' Get the contents of the file
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.webjx.com" ' address of the page to read
Response.Write "Start updating the home page ..."
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

' Address of the page to be stored
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> 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.

Want to be useful to friends who are looking for an ASP-generated 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.