如何读取ASP输出的html源代码

html-css05

如何读取ASP输出的html源代码,第1张

<%

On Error Resume Next

dim conn

dim connstr

dim webdb

webdb="xqloginback/xqjtDatabase/xqjtdb.mdb"

Set conn = Server.CreateObject("ADODB.Connection")

connstr="Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &Server.MapPath(""&webdb&"")

conn.Open connstr

newlist=""

set rs=server.CreateObject("adodb.recordset")

sql="select id,name,addtime from new order by id desc"

rs.open sql,conn,1,1

pagesum=10

topage=clng(request("topage"))

if topage<1 then topage=1

rs.pagesize=pagesum

if not rs.eof then

rs.absolutepage=topage

end if

no=1

do while not rs.eof and not rs.bof and pagesum>0

newlist=newlis&"<table width='90%' height='25' border='0' align='center' cellspacing='0'>"

newlist=newlis&"<tr>"

newlist=newlis&"<td width='539'><a href='new_view.asp?id="&rs("id")&"' target='_blank'>"&rs("name")&" </a></td>"

newlist=newlis&"</tr></table>"

<%

rs.movenext

pagesum=pagesum-1

no=no+1

loop

Set fso = Server.CreateObject("Scripting.FileSystemObject")

Set templates = fso.OpenTextFile(server.MapPath("template.html"))

str=templates.readall()'读出结果,赋值给str

set fso=nothing

set templates=nothing

str=replace(str,"$newlist$",newlist)

fileName="28ke.html"

Set createHtml = Server.CreateObject("Scripting.FileSystemObject")

Set htmlFile = createHtml.CreateTextFile(server.MapPath(fileName))

htmlFile.write(str)

set htmlFile=nothing

set createHtml=nothing

%>

ASP是动态服务器页面(Active Server Page)的英文缩写。[1] 是微软公司开发的代替CGI脚本程序的一种应用,它可以与数据库和其它程序进行交互,是一种简单、方便的编程工具。ASP的网页文件的格式是 .asp。现在常用于各种动态网站中。

.NET是 Microsoft XML Web services 平台。XML Web services 允许应用程序通过 Internet 进行通讯和共享数据,而不管所采用的是哪种操作系统、设备或编程语言。Microsoft .NET 平台提供创建 XML Web services 并将这些服务集成在一起之所需。对个人用户的好处是无缝的、吸引人的体验。

PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域。PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。它可以比CGI或者Perl更快速地执行动态网页。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执行编译后代码,编译可以达到加密和优化代码运行,使代码运行更快。

HTML(Hyper Text Mark-up Language )即超文本标记语言,是 WWW 的描述语言,由 Tim Berners-lee提出。设计 HTML 语言的目的是为了能把存放在一台电脑中的文本或图形与另一台电脑中的文本或图形方便地联系在一起,形成有机的整体,人们不用考虑具体信息是在当前电脑上还是在网络的其它电脑上。这样,你只要使用鼠标在某一文档中点取一个图标,Internet就会马上转到与此图标相关的内容上去,而这些信息可能存放在网络的另一台电脑中。

HTML文本是由 HTML命令组成的描述性文本,HTML 命令可以说明文字、 图形、动画、声音、表格、链接等。 HTML的结构包括头部 (Head)、主体 (Body) 两大部分。头部描述浏览器所需的信息,主体包含所要说明的具体内容。

他们并无什么明显区别,只是开发工具不同,从网页编译后展现出来的还是html网页形式

把下面的代码存为html.asp,代码中相关按自己要求修改,1.htm和1.asp<%

filename="1.htm"

if request("body")<>"" then

Set fso = Server.CreateObject("Scripting.FileSystemObject")

Set fout = fso.CreateTextFile(server.mappath(""&filename&""))

fout.Write request("body")

fout.close

set fout=nothing

set fso=nothing

mskrindex="ok"

end if

%>

<script language="Javascript">

<!-- hide

function insertsmilie(smilieface){ document.frmAnnounce.body.value+=smilieface}

// -->

</script>

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>生成html</title>

</head>

<body>

<%if mskrindex="ok" then%>

<p></p>

<table border="0" cellspacing="0" width="80%" cellpadding="5">

<tr>

<td align="center">

<font color="red">√</font><%=Now()%>生成成功,点击浏览<a target="_blank" href="<%=filename%>"><%=filename%></a>

</td>

</tr>

</table>

<%else%>

<table width="95%" border="0" cellspacing="0" cellpadding="2">

<tr>

<form name="frmAnnounce" method="post" action="html.asp">

<td>

<font color="red"><b>生成</b>(生成文件为:<%=filename%>)</font>

</td>

</tr>

</table>

<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" height="90%">

<tr>

<td>

<textarea style="width:98%height:90%" name="body"><!--#include file="1.asp"--></textarea>

<input type="submit" name="Submit" value="生成">

</td>

</form>

</tr>

</table>

<%

end if

%>

</body>

</html>