| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 854 人关注过本帖
标题:高手看看我这个 asp转html 带分页的 代码 效率好不好
只看楼主 加入收藏
guang2356447
Rank: 2
等 级:论坛游民
帖 子:434
专家分:31
注 册:2007-7-10
结帖率:65.85%
收藏
 问题点数:0 回复次数:3 
高手看看我这个 asp转html 带分页的 代码 效率好不好
高手看看我这个 asp转html  带分页的 代码 效率好不好  

高手有更好的办法没     总觉的这个慢     我这个是发一个新的记录  就要重新生产所有的发页页面
比如总共3页    index1.html   index2.html  index3.html
要是我新加记录出现index4.html    1   2   3  4我都要重新生产一遍

首先是 添加保存的代码如下
<!--#include file="conn.asp"-->
 <%   
  set rs=server.createobject("adodb.recordset")   
  sql="select * from xw"   
  rs.open sql,conn,1,3   
  rs.addnew   
  rs("bt")=request.Form("bt")
  rs("nr")=request.Form("nr")
  rs("xh")=request.Form("xh")
  rs("sjh")=request.Form("sjh")
  rs.update
rs.close
set rs=nothing
response.Redirect("html2.asp?id="&request.Form("sjh")&"")              //sjh  就是要生产的页面名称
%>

下面是html2.asp的代码
<!--#include file="conn.asp"-->
<%
Function GetPage(url)
 '获得文件内容
 dim Retrieval
 Set Retrieval = server.CreateObject("Microsoft.XMLHTTP")
 With Retrieval
  .Open "Get", url, False ', "", ""
  .Send
  GetPage = BytesToBstr(.ResponseBody)
 End With
 Set Retrieval = Nothing
End Function

Function BytesToBstr(body)
 dim objstream
 set objstream = Server.CreateObject("adodb.stream")
 objstream.Type = 1
 objstream.Mode =3
 objstream.Open
 objstream.Write body
 objstream.Position = 0
 objstream.Type = 2
 objstream.Charset = "GB2312"
 BytesToBstr = objstream.ReadText
 objstream.Close
 set objstream = nothing
End Function

on error resume next
Url="http://localhost:90/html/xx.asp?id="&request.QueryString("id")&""'要读取的页面地址
response.write "开始更新首页..."
wstr = GetPage(Url)

'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")

'if not MyFile.FolderExists(server.MapPath("/html/")) then
'MyFile.CreateFolder(server.MapPath("/html/"))'
'end if

'要存放的页面地址
dizhi=server.MapPath("jt/"&request.QueryString("id")&".html")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If

Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
crfi.close
fs.close
set CrFi=nothing
set fs=nothing
response.write "...<font color=red>"&request.QueryString("id")&"更新完成!</font>"

sql="select * from xw"
set rs=server.createObject("ADODB.Recordset")
rs.open sql,conn,1,1
rs.pagesize=3
zh=rs.pagecount
rs.close
set rs=nothing
response.Redirect("htmlpage.asp?id="&zh&"")       //这个是吧 数据库中的总分页数传给  下个页面
%>

下面是htmlpage.asp的代码
<%
Function GetPage(url)
 '获得文件内容
 dim Retrieval
 Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
 With Retrieval
  .Open "Get", url, False ', "", ""
  .Send
  GetPage = BytesToBstr(.ResponseBody)
 End With
 Set Retrieval = Nothing
End Function

Function BytesToBstr(body)
 dim objstream
 set objstream = Server.CreateObject("adodb.stream")
 objstream.Type = 1
 objstream.Mode =3
 objstream.Open
 objstream.Write body
 objstream.Position = 0
 objstream.Type = 2
 objstream.Charset = "GB2312"
 BytesToBstr = objstream.ReadText
 objstream.Close
 set objstream = nothing
End Function


aa=request.QueryString("id")      //这里循环生产所有分页的页面
for count=1 to aa


on error resume next
Url="http://localhost:90/html/indexqq.asp?page="&count&""'要读取的页面地址
response.write "开始更新首页..."
wstr = GetPage(Url)

'response.write(wstr)
Set fs=Server.CreateObject("Scripting.FileSystemObject")

'if not MyFile.FolderExists(server.MapPath("/html/")) then
'MyFile.CreateFolder(server.MapPath("/html/"))'
'end if

'要存放的页面地址
dizhi=server.MapPath("jt/index-"&count&".html")
If (fs.FileExists(dizhi)) Then
fs.DeleteFile(dizhi)
End If

Set CrFi=fs.CreateTextFile(dizhi)
Crfi.Writeline(wstr)
crfi.close
fs.close
set CrFi=nothing
set fs=nothing
response.write "...<font color=red>index-"&count&".html更新完成!</font><br>"
%>
<%
next
%>

搜索更多相关主题的帖子: 效率 asp html 代码 
2010-06-15 15:55
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
个人觉得ASP做这个伪静态比纯静态生成html效率要好。
2010-06-15 19:01
guang2356447
Rank: 2
等 级:论坛游民
帖 子:434
专家分:31
注 册:2007-7-10
收藏
得分:0 
你有实现伪静态的好方法没
2010-06-16 14:01
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
ASP的话方法不太多使用Rewrite插件来实现。
2010-06-16 15:57
快速回复:高手看看我这个 asp转html 带分页的 代码 效率好不好
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026048 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved