设为首页
加入收藏
站内地图
旧版入口
当前位置:首页 > 站长学院 > 网络编程 > ASP

简单析取html文件实例

作者:佚名 出处:网络转载 时间:11-19 点击:

内容载入中...
用offline下载了一些小说,放在局域网上,想用自己设计的页面显示,内容放在一个table中,如果取全部HTML,会有效果问题,因此只取<body ....> </body>之间的,代码如下:
<%
dim filepath
filepath=replace(Request.QueryString ("tar"),chr(34),"")
filepath=Server.MapPath(filepath)
set x=server.CreateObject ("Scripting.FileSystemObject")
set y=x.OpenTextFile (filepath,1,false)
result=y.readall()
y.close
set y=nothing
set x=nothing
'end if
result=lcase(result)
''''''''''''''''''''''''
result=mid(result,instr(result,"<body"),instr(result,"</body>"))
result=replace(result,"</body>","")
result=mid(result,instr(result,">")+1)
''''''''''''''''''''''''
''以下,把所有打开文件中的连接转换
''<a href="c.HTML">---><a href="show.ASP?tar=c.HTML">
''               或---><a href="show.ASP?tar=a/b/c.HTML">
if instr(request.querystring("tar"),"/")<>0 then
dim temp
temp=left(request.querystring("tar"),instrrev(request.querystring("tar"),"/"))
result=replace(result,"href=../../" & chr(34),"href=../../" & chr(34) & "show.ASP?tar=" & temp)

else
''
result=replace(result,"href=../../" & chr(34),"href=../../" & chr(34) & "show.ASP?tar=")
end if
Response.Write "<pre>" & result & "</pre>"
%>
收藏本文:
】【打印页面】【推荐给朋友】【关闭窗口

站长学院

推荐信息