asp

位置:IT落伍者 >> asp >> 浏览文章

ASP生成html的新方法


发布日期:2018年10月19日
 
ASP生成html的新方法

已经有很多生成html的新闻系统但是都是用的模板本函数实现把asp页面产生的html代码保存成为一个html文件这样就没有必要改动原来的页面就可以轻松完成一个生成html的新闻系统了^_^
由于代码比较短这里就不进行注释了

以下为引用的内容
<%
当目标页面的包含文件即#include的页面里边存在responseEnd()的时候本程序有问题
注意本文件一定要放在htm指向的文件的同一目录下
dim hughchiu_rtcode
Function get_exe_code(htm)
dim execode
dim tmp_str
Dim rerecontentfsofaspStartaspEnd
dim msm
execode = ""
set fso=CreateObject("ScriptingFileSystemObject")
set f=fsoOpenTextFile(servermappath(htm))
content=fReadAll
fclose
set f=nothing
set fso=nothing

set re = new regexp
reignorecase = true
reglobal = true
repattern = "<%@[^%]+%>"
content = rereplace(content"")

reglobal = false
repattern = "<!s*#includes*files*=s*""([^""]+)""s*>"
do
set ms = reexecute(content)
if mscount<> then
set m = ms()
tmp_str = get_exe_code(msubmatches())
content = rereplace(content tmp_str)
else
exit do
end if
loop
set m = nothing
set ms = nothing

repattern="^s*="
aspEnd=
aspStart=inStr(aspEndcontent"<%")+

set re=new RegExp
reignorecase = true
reglobal = false
repattern = "responseWrite(+)"

do while aspStart>aspEnd+
execode = execode&vbcrlf&" hughchiu_rtcode = hughchiu_rtcode&"""&replace( replace(Mid(contentaspEndaspStartaspEnd)"""""""""") vbcrlf """&vbcrlf&""")&""""&vbcrlf
aspEnd=inStr(aspStartcontent"%>")+
tmp_str = Mid(contentaspStartaspEndaspStart)

do
set ms = reexecute(tmp_str)
if mscount<> then
set m = ms()
tmp_str = rereplace(tmp_str " hughchiu_rtcode = hughchiu_rtcode&"&msubmatches())
else
exit do
end if
loop

set m = nothing
set ms = nothing

execode = execode& rereplace(tmp_str"hughchiu_rtcode = hughchiu_rtcode&")

aspStart=inStr(aspEndcontent"<%")+
loop

set re = nothing
set re=nothing

execode = execode&vbcrlf&" hughchiu_rtcode = hughchiu_rtcode&"""&replace( replace(Mid(contentaspEnd) """" """""") vbcrlf """&vbcrlf&""" )&""""&vbcrlf
get_exe_code = "<%"&execode&"%>"
End Function

function asphtml(htm)
dim code
code = replace( replace( replace( get_exe_code(htm) "hughchiu_rtcode = hughchiu_rtcode&"""""&vbcrlf "" ) "<%" "" ) "%>" "" )
responseWrite(code)
execute(code)
responseWrite( hughchiu_rtcode )
asphtml = hughchiu_rtcode
end function
%>

使用范例

以下为引用的内容


set fso=CreateObject("ScriptingFileSystemObject")
set f=fsoCreateTextFile( servermappath( "youpagehtm" ) true )
fWriteLine( asphtml("youpageasp") )
fclose
set f = nothing
set fso = nothing

               

上一篇:ASP Cookies 教程

下一篇:asp FSO 读写文件本文件实现代码