博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一个用ASP生成html的新方法
阅读量:7078 次
发布时间:2019-06-28

本文共 2460 字,大约阅读时间需要 8 分钟。

目前已经有很多生成html的新闻系统,但是都是用的模板,本函数实现把asp页面产生的html代码保存成为一个html文件,这样就没有必要改动原来的页面就可以轻松完成一个生成html的新闻系统了。^_^   由于代码比较短,这里就不进行注释了<%'当目标页面的包含文件即#include的页面里边存在response.End()的时候本程序有问题'注意:本文件一定要放在20041227111723.htm指向的文件的同一目录下dim hughchiu_rtcodeFunction get_exe_code(20041227111723.htm)dim execodedim tmp_strDim re,re1,content,fso,f,aspStart,aspEnddim ms,mexecode = ""set fso=CreateObject("Scripting.FileSystemObject")set f=fso.OpenTextFile(server.mappath(20041227111723.htm))content=f.ReadAllf.closeset f=nothingset fso=nothingset re = new regexpre.ignorecase = truere.global = truere.pattern = "\<\%\@[^\%]+\%\>"content = re.replace(content,"")re.global = falsere.pattern = "\<\!\-\-\s*\#include\s*file\s*=\s*\""([^\""]+)\""\s*\-\-\>"doset ms = re.execute(content)if ms.count<>0 thenset m = ms(0)tmp_str = get_exe_code(m.submatches(0))content = re.replace(content, tmp_str)elseexit doend ifloopset m = nothingset ms = nothingre.pattern="^\s*="aspEnd=1aspStart=inStr(aspEnd,content,"<%")+2set re1=new RegExpre1.ignorecase = truere1.global = falsere1.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&""")&""""&vbcrlfaspEnd=inStr(aspStart,content,"%\>")+2tmp_str = Mid(content,aspStart,aspEnd-aspStart-2)doset ms = re1.execute(tmp_str)if ms.count<>0 thenset m = ms(0)tmp_str = re1.replace(tmp_str, " hughchiu_rtcode = hughchiu_rtcode&"&m.submatches(0))elseexit doend ifloopset m = nothingset ms = nothingexecode = execode& re.replace(tmp_str,"hughchiu_rtcode = hughchiu_rtcode&")aspStart=inStr(aspEnd,content,"<%")+2loopset re1 = nothingset re=nothingexecode = execode&vbcrlf&" hughchiu_rtcode = hughchiu_rtcode&"""&replace( replace(Mid(content,aspEnd), """", """"""), vbcrlf, """&vbcrlf&""" )&""""&vbcrlfget_exe_code = "<%"&execode&"%\>"End Functionfunction asp2html(20041227111723.htm)dim codecode = replace( replace( replace( get_exe_code(20041227111723.htm), "hughchiu_rtcode = hughchiu_rtcode&"""""&vbcrlf, "" ), "<%", "" ), "%\>", "" )'response.Write(code)execute(code)'response.Write( hughchiu_rtcode )asp2html = hughchiu_rtcodeend function%>使用范例:  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

  

转载于:https://www.cnblogs.com/uuxanet/p/3282873.html

你可能感兴趣的文章
xtrabackup 在线主从搭建
查看>>
dm6446开发大全资料号称宇宙最全
查看>>
for循环中变量i值的理解
查看>>
Go之路
查看>>
面向对象(中)之二
查看>>
[C#]获取指定文件夹下的所有文件名(递归)
查看>>
浏览器兼容处理
查看>>
ubuntu下直接可视化访问服务器文件夹方法
查看>>
linux终端下查Dict.cn/WebsterOnline/Etymonline.com
查看>>
如何使用ASP.NET开发基于推技术的聊天室?
查看>>
redis-主从复制
查看>>
《小账本》开发日志 第六天
查看>>
第九周总结
查看>>
173. Binary Search Tree Iterator
查看>>
python_正则表达式匹配ip
查看>>
json数据导出excel
查看>>
Appium 服务器参数
查看>>
Openssl源代码整理学习---含P7/P10/P12说明
查看>>
TP90 95 99指标
查看>>
进度条2
查看>>