请问如何生成文章的内部分页呢?如文章是3页的话生成1_1.html,1_2.html,1_3.html.谢谢。

fwy12 2010-10-13 04:13:31
我是用如下代码生成文章静态页的,请问如何生成文章的内部分页呢?

如文章是3页的话生成1_1.html,1_2.html,1_3.html.谢谢。


<!--#include file="../../Inc/conn.asp"-->
<!--#include file="../../Inc/ubb.asp"-->
<!--#include file="../../Inc/fenye.asp"-->
<!--#include file="../../Inc.asp"-->
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Const HTML_Article_Path = "html/"
ID=request("id")
Page = Request.QueryString("Page")
If Page = "" Then Page = 1
Call Article_Page_Html(ID,Page)
Private Sub Article_Page_Html(ID,iPage)
If Page = 1 Then
FilePath = "../" & HTML_Article_Path & ID & ".html"
Else
FilePath = "../" & HTML_Article_Path & ID & "_" & Page & ".html"
End If

FromURL = "http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&Page=" & iPage & "&rnd=" & Now()

Call ToHtml(FromURL,FilePath)
End Sub

Private Sub ToHtml(FromURL,FilePath)
Response.Write("<a href=""" & FilePath & """ target=""_blank"">" & FilePath & " --> Ok</a><br>")
FilePath = Server.MapPath(FilePath)
Set objXmlHttp=Server.createObject("Microsoft." & "XMLHTTP")
objXmlHttp.open "GET",FromURL,false
objXmlHttp.send()
binFileData=objXmlHttp.responseBody
Set objXmlHttp = Nothing
Set objAdoStream=Server.createObject("ADODB." & "Stream")
objAdoStream.Type=1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2
objAdoStream.Close()
Set objAdoStream = Nothing
End Sub
%>
...全文
344 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChinaXtHuLang 2010-11-02
  • 打赏
  • 举报
回复
发你的邮箱。我发你份。
fwy12 2010-11-02
  • 打赏
  • 举报
回复
看来的多学习啦,这个分页问题还是没搞定的
as123456789d 2010-11-02
  • 打赏
  • 举报
回复
非常感谢 !!!!, 已经看了,,
ChinaXtHuLang 2010-11-02
  • 打赏
  • 举报
回复
[Quote=引用 21 楼 as123456789d 的回复:]

给我一份吧,,,623669584@qq.com 谢谢 生成这一块 还有不懂的地方 httP://www.asp211.com
您的位置:链接有问题,不知道 这地方 有没有好的方法解决,我想了一种 不过很麻烦,
[/Quote]
已发送
No1bigtooth 2010-11-02
  • 打赏
  • 举报
回复
学 习
as123456789d 2010-11-02
  • 打赏
  • 举报
回复
给我一份吧,,,623669584@qq.com 谢谢 生成这一块 还有不懂的地方 httP://www.asp211.com
您的位置:链接有问题,不知道 这地方 有没有好的方法解决,我想了一种 不过很麻烦,
fwy12 2010-10-15
  • 打赏
  • 举报
回复
呵呵呵,看样子还有很多东西要学习哦
ChinaXtHuLang 2010-10-14
  • 打赏
  • 举报
回复
list.asp页面中的代码发下啊。
fwy12 2010-10-14
  • 打赏
  • 举报
回复
恢复楼上的,list不是列表页,是显示文章的。我的列表页是class。asp
ChinaXtHuLang 2010-10-14
  • 打赏
  • 举报
回复
其中32行就是
FromURL = http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&Page=" & iPage & "&rnd=" & Now()

这里。你调用的是:list.asp这个页面估计是你的列表页。
你现在要生成的是内容页。你用列表页干什么了??
fwy12 2010-10-14
  • 打赏
  • 举报
回复
根据楼上兄弟提示,我修改成代码,但是,运行的时候提示:
Microsoft VBScript 编译器错误 '800a0400'

缺少语句

\admin\save.asp, line 32

其中32行就是
FromURL = http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&Page=" & iPage & "&rnd=" & Now()
为什么会缺少语句呢?
<!--#include file="../../Inc/conn.asp"-->
<!--#include file="../../Inc/ubb.asp"-->
<!--#include file="../../Inc/fenye.asp"-->
<!--#include file="../../Inc.asp"-->
<%id=request("id")%>
<%
Sub ArtHtml(ID)
Dim ChannelDir
ChannelDir = "../html/"
Call oCreateFolder(ChannelDir)
Sql="Select ID,Content From Yao_Article Where Yn = 0 "
If ID <> "" Then
Sql=Sql& " And ID = "&ID&""
End If
Sql=Sql & " order by ID desc"
Set oRs = Conn.Execute(Sql)
If Not oRs.EOF Then
ID = oRs(0)
Content = oRs(1)
End If
oRs.Close
Set oRs = Nothing
If InStr(Content,"[yao_page]") > 0 Then
Content_Tmp = Split(Content,"[yao_page]")
Page_Count = Ubound(Content_Tmp)+1
For iPage=1 To Page_Count
If iPage = 1 Then
FilePath = ChannelDir & ID & ".html"
Else
FilePath = ChannelDir & ID & "_" & iPage & ".html"
End If
FromURL = http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&Page=" & iPage & "&rnd=" & Now()
Call ToHtml(FromURL,FilePath)
Next
Else
FilePath = ChannelDir & ID & ".html"
FromURL = http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&rnd=" & Now()
Call ToHtml(FromURL,FilePath)
End If
End Sub

Private Sub ToHtml(FromURL,FilePath)
Response.Write("<a href=""" & FilePath & """ target=""_blank"">" & FilePath & " --> Ok</a><br>")
FilePath = Server.MapPath(FilePath)
Set objXmlHttp=Server.createObject("Microsoft." & "XMLHTTP")
objXmlHttp.open "GET",FromURL,false
objXmlHttp.send()
binFileData=objXmlHttp.responseBody
Set objXmlHttp = Nothing
Set objAdoStream=Server.createObject("ADODB." & "Stream")
objAdoStream.Type=1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2
objAdoStream.Close()
Set objAdoStream = Nothing
End Sub

%>
  • 打赏
  • 举报
回复
正则很简单的
比如你的总页数是这么写的

总共10页

那么你就可以

pat="总共(\d+)页"
Set r = New Regexp'设置配置对象
r.IgnoreCase = True'忽略大小写
r.Global = True'设置为全文搜索
r.MultiLine = true '多行
r.Pattern = pat'正则表达式
Set Matches =r.Execute(binFileData)'开始执行配置
set r=nothing
s=""
For Each m in Matches
s=m.SubMatches(0)'循环匹配
Exit For
Next
response.write s
fwy12 2010-10-14
  • 打赏
  • 举报
回复
请问如何用正则提取binFileData这个内容的总页数呢?
  • 打赏
  • 举报
回复
你可以用你原来的代码
可不需要改

按我3楼的说明去做即可
fwy12 2010-10-14
  • 打赏
  • 举报
回复
好的,谢谢、我在自己琢磨琢磨。
ChinaXtHuLang 2010-10-14
  • 打赏
  • 举报
回复
晕死。。
Sub ArtHtml(ID)
Dim ChannelDir
ChannelDir = "../html/"
Call oCreateFolder(ChannelDir)'这行代码你知道什么意思吗?这是用的一个创建文件夹的函数。你没有这个运行就出错。
还有下面的。
不知道你怎么弄的。
FromURL = http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&Page=" & iPage & "&rnd=" & Now()
Call ToHtml(FromURL,FilePath)
Next
Else
FilePath = ChannelDir & ID & ".html"
FromURL = http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&rnd=" & Now()
改成:

FromURL = GetPageUrlPath&"list.asp?id=" & ID & "&Page=" & iPage & "&rnd=" & Now()
Call ToHtml(FromURL,FilePath)
Next
Else
FilePath = ChannelDir & ID & ".html"
FromURL = GetPageUrlPath&"list.asp?id=" & ID & "&rnd=" & Now()


Function GetPageUrlPath()
server_name = request.servervariables("server_name")
server_port = request.servervariables("server_port")
path_info = request.servervariables("path_info")
path_tmp = Split(path_info, "/")
path_info = Replace(path_info, path_tmp(UBound(path_tmp)), "")
url = "http://" & server_name
If server_port<>80 Then url = url & ":" & server_port
url = url & path_info
GetPageUrlPath = url
End Function


实在不行。你自己就琢磨下。我要上班做事了。
fwy12 2010-10-14
  • 打赏
  • 举报
回复
多谢楼上兄弟的提醒,不过我运行http://localhost/admin/save.asp和运行http://localhost/admin/save.asp?id=230都还是提示:
Microsoft VBScript 编译器错误 '800a0400'

缺少语句

\admin\save.asp, line 32

其中32行就是
FromURL = http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&Page=" & iPage & "&rnd=" & Now()
ChinaXtHuLang 2010-10-14
  • 打赏
  • 举报
回复
if rs("yn")= 0 then 
Response.Write(Content)
end if
改成:
if rs("yn")= 0 then
Call OutContent(id,Content,"/html/")
end if
Sub OutContent(aID,Content,PagePath)
thisPage = Request.QueryString("thisPage")
If thisPage<>"" Then thisPage = Cint(thisPage)

If thisPage="" Then thisPage=1
thisPage = Cint(thisPage)
Content_Tmp = Split(Content,"[NextPage]")
Page_Count = Ubound(Content_Tmp)+1
If thisPage> Page_Count Then thisPage = Page_Count

Response.Write(Content_Tmp(thisPage-1))

If Page_Count>1 Then
Response.Write("<div class=""thisPageNav"">")
For iPage=1 To Page_Count
If iPage = 1 Then
URL = PagePath & "/" & aID & ".html"
Else
URL = PagePath & "/" & aID & "_" & iPage & ".html"
End If
If iPage = thisPage Then
Response.Write("<strong>第" & iPage & "页</strong> ")
Else
Response.Write("<a href=""" & URL & """>第" & iPage & "页</a> ")
End If
Next
Response.Write("</div>")
End If
End Sub
fwy12 2010-10-14
  • 打赏
  • 举报
回复
list.asp的代码如下:
<!--#include file="Inc/conn.asp"-->
<!--#include file="Inc/ubb.asp"-->
<!--#include file="Inc/fenye.asp"-->
<!--#include file="Inc.asp"-->
<%
Dim ID,page
ID=LaoYRequest(request("id"))
page=LaoYRequest(Request("Page"))
set rs=server.createobject("adodb.recordset")
sql="select * from "&tbname&"_Article where id="&id
rs.open sql,conn,1,1
if rs.eof and rs.bof then
Call Alert("不正确的ID!",SitePath)
else

If rs("Linkurl")<>"" then
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>转向:<%=rs("title")%></title>
<style>
#ndiv{
width:450px;
padding:8px;
margin-top:8px;
background-color:#FCFFF0;
border:3px solid #B4EF94;
height:100px;
text-align:left;
font-size:14px;
line-height:180%;
}
</style>
<meta http-equiv="refresh" content="1;URL=<%=rs("LinkUrl")%>">
</head>
<body>
<div align='center'>
<div id='ndiv'>
正在转向:<a href='<%=rs("LinkUrl")%>'><%=rs("LinkUrl")%></a>,请稍候...
</div>
</div>
</body>
</html>
<%
Response.End
Else

set rsClass=server.createobject("adodb.recordset")
sql = "select * from "&tbname&"_Class where ID="&rs("ClassID")&""
rsClass.open sql,conn,1,1
if rsClass.eof and rsClass.bof then
Call Alert("没有此分类,返回首页!","index.asp")
else
ClassName=rsClass("ClassName")
TopID=rsClass("TopID")
rsClass.close
set rsClass=nothing
end if

If rs("PageNum")=0 then
Content=ManualPagination1(""&rs("ID")&"",""&UBBCode(rs("Content"))&"")
else
Content=AutoPagination1(""&rs("ID")&"",""&UBBCode(rs("Content"))&"",rs("PageNum"))
End if
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<%=Sitekeywords%>" />
<meta name="description" content="<%=left(LoseHtml(rs("Content")),120)%>" />
<link href="<%=SitePath%>images/css<%=Css%>.css" ID="skin" type=text/css rel=stylesheet>
<link rel="shortcut icon" href="<%=SitePath%>images/myfav.ico" type="image/x-icon" />
<script type="text/javascript" src="<%=SitePath%>inc/main.asp"></script>
<title><%=rs("Title")%><%=IIF(page>0,"("&page&")","")%>-<%=ClassName%>-<%=SiteTitle%></title>
</head>
<body<%If ""&IsPing&""=1 then%> onLoad="showre(<%=ID%>,1)"<%end if%>>
<div class="mwall">
<%=Head%>
<%=Menu%><div class="mw">
<div class="dh">
<%=search%>您现在的位置:<a href="<%=SitePath%>">首页</a> >> <%If TopID>0 then Response.Write("<a href="""&SitePath&"Class.asp?ID="&TopID&""">"&Classlist(TopID)&"</a> >> ") End if%><a href="<%=SitePath%>Class.asp?ID=<%=rs("ClassID")%>"><%=Classlist(rs("ClassID"))%></a> >> 内容
</div>
<div id="nw_left">
<div id="web2l">
<h1><%=rs("Title")%><%=IIF(page>0,"("&page&")","")%></h1>
<h3>时间:<%=rs("DateAndTime")%><%If IsHits=1 then%> 点击: <% If Html=3 then %><script language="javascript" src="count.asp?id=<%=rs("id")%>"></script>次 <% else%><%=rs("hits")%>次<%end if%>
<%End if%></h3>
<div id="content">
<%If Iszhaiyao=1 and b<2 then%><div class="zhaiyao"><b>  核心提示:</b><%=left(rs("Artdescription"),150)%>...</div><%End if%>
<%Call ShowAD(1)%>
<%
If rs("yn")=2 then
If rs("UserName") = LaoYName then
Response.Write(Content)
else
Response.Write("<div style=""margin:40px auto;text-align:center;color:#ff0000;"">会员私有文章,禁止查看!</div>")
End if
end if

if rs("yn")=1 then
Response.Write("<div style=""margin:40px auto;text-align:center;color:#ff0000;"">该文章还没有通过审核</div>")
end if

if rs("yn")= 0 then
Response.Write(Content)
end if
%>
</div>
<div id="copy"><%If IsAuthor =1 then%>作者:<%=rs("author")%><%End if:If rs("UserID")<>0 then Response.Write(" 录入:<a href="""&SitePath&"User/ShowUser.asp?UserName="&rs("UserName")&""" title=""点击查看资料""><u>"&rs("UserName")&"</u></a>") end if%> <%If IsFrom =1 then%>来源:<%=rs("CopyFrom")%><%End if%></div>
<%If rs("Vote")<>"" then Response.Write(""&ShowVoteList2(rs("Vote"))&"") End if%>
<%If Iswz=1 then%><script type="text/javascript" src="<%=SitePath%>images/wz.js"></script><%End if%>
<% If Html=2 then %>
<script src="adshow.asp?id=3"></script>
<% else%>
<%Call ShowAD(2)%>
<%end if%>

<%If mood=1 then%><div style="margin:0 auto;width:530px;">
<script language="javascript">
var infoid = '<%=ID%>';
</script>
<script language = "JavaScript" src ="<%=SitePath%>Inc/mood.asp?ID=<%=ID%>"></script>
</div><%End if%>
<div class="sxart">
<%=thehead%><%=thenext%>
</div>
</div>
<div id="web2l">
<h6>相关文章</h6>
<div id="marticle">
<ul>
<% If Html=3 then %>
<table border="0" id="table1" cellspacing="0" cellpadding="0">
<tr>
<td width="300"><script language="javascript" src="xiangguan.asp?key=<%=rs("KeyWord")%>&n=10"></script></td>
<td width="310"><script language="javascript" src="xiangguan2.asp?key=<%=rs("KeyWord")%>&n=10"></script></td>
</tr>
</table>

<% else%>
<%=ShowMutualityArticle(a,rs("KeyWord"),20,"·",0)%>
<%end if%>
</ul>
</div>
<div id="clear"></div>
</div><%If IsPing=1 then%>
<div id="web2l">
<h6>相关评论</h6>
<div id="list"><img src="<%=SiteTable%>images/loading.gif" /></div>
<div id="MultiPage"></div>
<div id="clear"></div>
<h6>发表我的评论</h6>
<div style="height:205px;">
<div class="pingp">
<%
If PingNum=0 then
%>
<% If Html=3 then %>
<script src="adshow.asp?id=5"></script>
<% else%>
<%Call ShowAD(5)%>
<%end if%>
<%
else
for i = 1 to PingNum%>
<img src="<%=SitePath%>images/faces/<%=i%>.gif" onclick='insertTags("[laoy:","]","<%=i%>")'/>
<%
Next
End if
%>
</div> <div class="artpl">
<ul>
<li>大名:<input name="memAuthor" type="text" class="borderall" id="memAuthor" value="<%If IsUser=1 then Response.Write(""&UserName&"") else Response.Write(""&iparray(GetIP)&"") End if%>" Readonly maxlength="8"/>
</li>
<li>内容:<textarea name="memContent" cols="30" rows="8" style="width:250px;height:120px;" wrap="virtual" id="memContent" class="borderall"/></textarea></li>
<li><input name="ArticleID" type="hidden" id="ArticleID" value="<%=ID%>" />
<input name="button3" type="button" class="borderall" id = "sendGuest" onClick="AddNew()" value="发 表" /></li>
</ul>
</div>
</div></div><%end if%>
</div>
<div id="nw_right">
<% If Html=3 then %>
<script src="adshow.asp?id=3"></script>
<% else%>
<%Call ShowAD(3)%>
<%end if%>
<div id="web2r">
<h5>本类热门</h5>
<ul id="list10">
<% If Html=3 then %>
<script language="javascript" src="hot.asp?classid=<%=rs("classid")%>&n=10"></script>
<% else%>
<%Call ShowArticle(""&rs("ClassID")&"",10,5,"·",100,"no","Hits desc,ID desc",0,0)%>
<%end if%>
</ul>
</div>
<div id="web2r">
<h5>本类推荐</h5>
<ul id="list10">
<% If Html=3 then %>
<script language="javascript" src="ishot.asp?classid=<%=rs("classid")%>&n=10"></script>
<% else%>

<%Call ShowArticle(""&rs("ClassID")&"",10,5,"·",100,"IsHot=1","ID desc",0,0)%>
<%end if%>
</ul>
</div>
<div id="web2r">
<h5>本类固顶</h5>
<ul id="list10">
<% If Html=3 then %>
<script language="javascript" src="istop.asp?classid=<%=rs("classid")%>&n=10"></script>
<% else%>

<%Call ShowArticle(""&rs("ClassID")&"",10,5,"·",100,"IsTop=1","ID desc",0,0)%>
<%end if%>
</ul>
</div>
</div>
</div>
<script type="text/javascript" src="<%=SitePath%>Ajaxpl.asp"></script>
<%End if%>
<%
rs.close
set rs=nothing
end if

if html<>3 then
If page = "" then
sql="Update "&tbname&"_Article set hits = hits + 1 where ID= "&ID
conn.execute(sql)
End if
end if

function thehead
headrs=server.CreateObject("adodb.recordset")
sql="select top 1 ID,Title from "&tbname&"_Article where id<"&id&" and ClassID="&rs("ClassID")&" order by id desc"
set headrs=conn.execute(sql)
if headrs.eof then
response.Write("<li>上一篇:没有了</li>")
else
a0=headrs("id")
a1=headrs("Title")
If html=1 then
response.Write("<li>上一篇:<a href='List.asp?ID="&a0&"'>"&a1&"</a></li>")
Else
response.Write("<li>上一篇:<a href='Html/?"&a0&".html'>"&a1&"</a></li>")
End if
end if
headrs.close
set headrs=nothing
end function

function thenext
newrs=server.CreateObject("adodb.recordset")
sql="select top 1 ID,Title from "&tbname&"_Article where id>"&id&" and ClassID="&rs("ClassID")&" order by id asc"
set newrs=conn.execute(sql)
if newrs.eof then
response.Write("<li>下一篇:没有了</li>")
else
a0=newrs("id")
a1=newrs("Title")
If html=1 then
response.Write("<li>下一篇:<a href='List.asp?ID="&a0&"'>"&a1&"</a></li>")
Else
response.Write("<li>下一篇:<a href='Html/?"&a0&".html'>"&a1&"</a></li>")
End if
end if
newrs.close
set newrs=nothing
end function
%>
<%=Copy%></div>
</body>
</html>
ChinaXtHuLang 2010-10-13
  • 打赏
  • 举报
回复
看了下。我记得好像是一个新闻的CMS写的。
你的内容分页那个过程没有内容。你怎么分页啊。。
Private Sub Article_Page_Html(ID,iPage)
'这里把ID传进来了。就要根据ID区你的文章表里面查询出该文章的内容。最后将内容进行分页处理
If Page = 1 Then
FilePath = "../" & HTML_Article_Path & ID & ".html"
Else
FilePath = "../" & HTML_Article_Path & ID & "_" & Page & ".html"
End If

FromURL = "http://"&request.ServerVariables("Server_NAME")&""&SitePath&"list.asp?id=" & ID & "&Page=" & iPage & "&rnd=" & Now()

Call ToHtml(FromURL,FilePath)
End Sub


参考下:
'==========================生成新闻文章静态页===================================
Sub ArtHtml(ID)
Dim ChannelDir
ChannelDir = "/art/"
Call oCreateFolder(ChannelDir)
Sql="Select ID,Content From Art Where 1 = 1 "
If ID <> "" Then
Sql=Sql& " And ID = "&ID&""
End If
Sql=Sql & " order by ID desc"
Set oRs = Conn.Execute(Sql)
If Not oRs.EOF Then
ID = oRs(0)
Content = oRs(1)
End If
oRs.Close
Set oRs = Nothing
If InStr(Content,"[NextPage]") > 0 Then
Content_Tmp = Split(Content,"[NextPage]")
Page_Count = Ubound(Content_Tmp)+1
For iPage=1 To Page_Count
If iPage = 1 Then
FilePath = ChannelDir & ID & ".html"
Else
FilePath = ChannelDir & ID & "_" & iPage & ".html"
End If
FromURL = Html_SysSiteUrl & "View_Art.asp?id=" & ID & "&thisPage=" & iPage & "&rnd=" & Now()
Call ToHtml(FromURL,FilePath)
Next
Else
FilePath = ChannelDir & ID & ".html"
FromURL = Html_SysSiteUrl & "View_Art.asp?id=" & ID & "&rnd=" & Now()
Call ToHtml(FromURL,FilePath)
End If
End Sub
加载更多回复(3)

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧