ASP生成html的新方法
来源:asp之家 发布时间:2011-04-02 11:04:00
由于代码比较短,这里就不进行注释了
代码如下:
<%
'当目标页面的包含文件即#include的页面里边存在response.End()的时候本程序有问题
'注意:本文件一定要放在20041227111723.htm指向的文件的同一目录下
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*\-\-\>"
do
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)
do
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( 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
%>
使用范例:
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


猜你喜欢
- 如何用Sleep函数编译一个定时组件?见下: Private Declare Sub Sleep L
- 1、接口概述1)、什么是接口?接口是提供了一种用以说明一个对象应该具有哪些方法的手段。尽管它可以表明这些方法的语义,但它并不规定这些方法应该
- SELECT表名=case when a.colorder=1 then d.name else '' end,表说明=ca
- 安装cmake,命令:pip install cmake安装VS选择C++的桌面开发和python开发给cl.exe配置环境变量。我的cl.
- 用wrapper封装这样在对象内外都可以访问function MapPool(){ function createMarker(n
- 如果用到数据筛选功能,可以使用x if condition else y的逻辑实现。如果使用的是纯Python,可以使用不断迭代的方式对每一
- matplotlib介绍Matplotlib 是 Python 的绘图库。 它可与 NumPy 一起使用,提供了一种有效的 MatLab 开
- 文本特征提取作用:对文本数据进行特征化(句子、短语、单词、字母)一般选用单词作为特征值方法一:CountVectorizersklearn.
- 测试环境 硬件:CPU 酷睿双核T5750 内存:2G 软件:Windows server 2003 + sql server 2005 O
- 一、系统简介实现一个学生信息的管理系统:主要功能有:添加学生信息删除学生信息修改学生信息查询学生信息显示学生信息退出当前系统二、步骤分析显示
- 引言事情是这样的,直接开讲面试官:npm run xxx的时候,发生了什么?讲的越详细越好。我(心想,简单啊): 首先,DNS 解析,将域名
- 前言 BeautifulSoup是主要以解析web网页的Python模块,它会提供一些强大的解释器,以解
- 相对或者绝对import 更多的复杂部分已经从python2.5以来实现:导入一个模块可以指定使用绝对或者包相对的导入。这个计划将移动到使绝
- 对于初学者,入门至关重要,这关系到初学者是从入门到精通还是从入门到放弃。以下是结合Python的学习经验,整理出的一条学习路径,主要有四个阶
- 接着上篇文章《解析SQL 表结构信息查询 含主外键、自增长》里面提到了INFORMATION_SCHEMA视图,其实到了SQL 2005微软
- 奥运来了,三大门户网站都加上了奥运主题。加上下面代码你的网站也拥有奥运主题了:<style type="text/
- HTTP头中一般断点下载时才用到Range和Content-Range实体头,Range用户请求头中,指定第一个字节的位置和最后一个字节的位
- 这个项目到一开始的kickoff到现在,持续了很长的一段时间,现在差不多也接近了尾声,所以要好好做个总结,下面不会设计到太多技术层面上的东西
- 字符串遍历>>> a_str = "hello itcast">>> for cha
- pytorch中我们有时候可能需要设定某些变量是参与训练的,这时候就需要查看哪些是可训练参数,以确定这些设置是成功的。pytorch中mod