New method of ASP generating HTML

Source: Internet
Author: User
Tags exit count end include

There are already a lot of HTML generated news systems, but all are used templates, this function implementation of the ASP page generated HTML code saved into an HTML file, so there is no need to change the original page can easily complete a generation of HTML news system. ^_^
Because the code is relatively short, there is no comment here

The following are the referenced contents:

<%
' When the target page contains the file that is the #include page, there is response. End () There is a problem with this procedure
' NOTE: This file must be placed in the same directory as the 20041227111723.htm pointing file
Dim Hughchiu_rtcode
Function Get_exe_code (20041227111723.htm)
Dim Execode
Dim tmp_str
Dim Re,re1,content,fso,f,aspstart,aspend
Dim ms,m
Execode = ""
Set Fso=createobject ("Scripting.FileSystemObject")
Set F=FSO. OpenTextFile (Server.MapPath (20041227111723.htm))
Content=f.readall
F.close
Set f=nothing
Set fso=nothing

Set re = new RegExp
Re.ignorecase = True
Re.global = True
Re.pattern = "\<\%\@[^\%]+\%\>"
Content = re.replace (content, "")

Re.global = False
Re.pattern = "\<\!\-\-\s*\ #include \s*file\s*=\s*\" ([^\ "]+) \" "\s*\-\-\>"
Todo
Set ms = Re.execute (content)
If Ms.count<>0 Then
Set m = ms (0)
Tmp_str = Get_exe_code (m.submatches (0))
Content = re.replace (content, TMP_STR)
Else
Exit Do
End If
Loop
Set m = Nothing
Set ms = Nothing

Re.pattern= "^\s*="
Aspend=1
Aspstart=instr (aspend,content, "<%") +2

Set Re1=new REGEXP
Re1.ignorecase = True
Re1.global = False
Re1.pattern = "response\." Write (. +) "

Do While aspstart>aspend+1
Execode = execode&vbcrlf& "Hughchiu_rtcode = hughchiu_rtcode&" "&replace (replace (Mid content,aspEnd , aspstart-aspend-2), "" "" "" "" "" "", vbCrLf, "" &vbcrlf& "" "" & "" "&vbcrlf
Aspend=instr (aspstart,content, "%\>") +2
Tmp_str = Mid (content,aspstart,aspend-aspstart-2)

Todo
Set ms = Re1.execute (TMP_STR)
If Ms.count<>0 Then
Set m = ms (0)
Tmp_str = Re1.replace (Tmp_str, "Hughchiu_rtcode = hughchiu_rtcode&" &m.submatches (0))
Else
Exit Do
End If
Loop

Set m = Nothing
Set ms = Nothing

Execode = execode& Re.replace (tmp_str, "Hughchiu_rtcode = hughchiu_rtcode&")

Aspstart=instr (aspend,content, "<%") +2
Loop

Set Re1 = Nothing
Set re=nothing

Execode = execode&vbcrlf& "Hughchiu_rtcode = hughchiu_rtcode&" "&replace (replace (Mid content,aspEnd "" "" "" "" "" "" "" "" "" &vbcrlf& "" "", "" "" "" "" "vbCrLf" "" &vbcrlf
Get_exe_code = "<%" &execode& "%\>"
End Function

function asp2html (20041227111723.htm)
Dim code
Code = replace (replace (Get_exe_code (20041227111723.htm), "Hughchiu_rtcode = hughchiu_rtcode&" "" "" "& vbCrLf, ""), "<%", "" "),"%\> "," "")
' Response. Write (Code)
Execute (Code)
' Response. Write (Hughchiu_rtcode)
asp2html = Hughchiu_rtcode
End Function
%>


Use Example:

The following are the referenced contents:

Set Fso=createobject ("Scripting.FileSystemObject")
Set F=FSO. CreateTextFile (Server.MapPath ("youpage.htm"), true)
F.writeline (asp2html ("youpage.asp"))
F.close
Set F = Nothing
Set fso = Nothing



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.