<SCRIPT language="JavaScript" src="../script/verify.js"></SCRIPT>
<TITLE>信息列表</TITLE>
</HEAD>
<BODY onscroll="onScroll()" >
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE></TITLE>
</HEAD>
<BODY>
<div id="menuChild" style="z-index:5;position:absolute;display:none;" onMouseOver="this.style.display='block'" onMouseOut="this.style.display='none'"></div>
</BODY>
</HTML><center>
<form method="post" action="DJOutputList.jsp?type=9" name="frmQuery" onSubmit="">
<input type="hidden" name="jsp_page" size="1" maxLength="12" value="list">
<input type="hidden" name="intperpagecount" size="1" maxLength="12" value="18">
<input type="hidden" name="sqlwhere" size="1" maxLength="12" value=" and a.rybh like '%'">
<input type="hidden" name="show_type"  value="simple">
<table id="DJZtry" width="100%" class="base_table">
<tr>
<td width="100%">
<table width="100%">
<tr>
<td width="40%"  align="left"><b><font color="#40668a" size="2">登记</font></b><font color="#40668a" size="2"><b>-&gt;&gt;信息列表</b></font></td> <td width="20%"  align="left">&nbsp;</td>
<td width="5%"align="right">

<input onclick="window.open('../include/contact.jsp?tabname=ztry_zp','showphoto','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=1000,height=800')" type="button" class="buttonNew"value="显示照片" name="Button1">
</td>
<td width="5%" align="right">
<input onclick="window.open('../include/exp_excel.jsp')" type="button" class="buttonNew"value="生成Excel" name="Button0">
</td>
<td width="5%"align="right">
<input type="button" value="返回" class="buttonNew" onclick="javascript:history.back();">
</td>
</tr>
<tr>
<td width="100%" height="24" colspan="10">
<table style="BORDER-COLLAPSE: collapse" borderColor="#111111" cellSpacing="1" border="1" borderColorDark="#4455aa" borderColorLight="#4455aa" height="20" width="100%" id="tt"> <tr align="center">
<td class=ColTitle >身份证号</td>
<td class=ColTitle >户籍地区划</td>
<td class=ColTitle >案件类别</td>
<td class=ColTitle >立案单位</td>
</tr>
<tr align="center" class="evenSelNone" onDblClick="openDetail(this)" onclick="rowSelected(this)" ref="DJOutputDetail.jsp?type=9&id=1100000000000014380">
<td class="ColValue" align="center">1</td>
<td class="ColValue" align="center"><a href="DJOutputDetail.jsp?type=9&id=1100000000000014380">1105280009992006120019</a></td>
<td class="ColValue" align="center">胡波</td>
<td class="ColValue" align="center">男</td>
<td class="ColValue" align="center">652801197603243437</td>
<td class="ColValue" align="center">锦江区</td>
<td class="ColValue" align="center">挪案</td>
<td class="ColValue" align="center">北察院</td>
</tr><tr align="center" class="evenSelNone" onDblClick="openDetail(this)" onclick="rowSelected(this)" ref="DJOutputDetail.jsp?type=9&id=1101010002001080027">
<td class="ColValue" align="center">3</td>
<td class="ColValue" align="center"><a href="DJOutputDetail.jsp?type=9&id=1101010002001080027">1101010009992001080027</a></td>
<td class="ColValue" align="center">刘明</td>
<td class="ColValue" align="center">男</td>
<td class="ColValue" align="center">110228195610300330</td>
<td class="ColValue" align="center">淀区</td>
<td class="ColValue" align="center">合同案</td>
<td class="ColValue" align="center">北京东城区</td>
</tr><tr align="center" class="evenSelNone" onDblClick="openDetail(this)" onclick="rowSelected(this)" ref="DJOutputDetail.jsp?type=9&id=1101010002001080076">
<td class="ColValue" align="center">4</td>
<td class="ColValue" align="center"><a href="DJOutputDetail.jsp?type=9&id=1101010002001080076">1101010009992001080076</a></td>
<td class="ColValue" align="center">张齐</td>
<td class="ColValue" align="center">男</td>
<td class="ColValue" align="center">110101196602112515</td>
<td class="ColValue" align="center">北阳区</td>
<td class="ColValue" align="center">贩品案</td>
<td class="ColValue" align="center">北城区</td>
</tr><tr align="center" class="evenSelNone" onDblClick="openDetail(this)" onclick="rowSelected(this)" ref="DJOutputDetail.jsp?type=9&id=1101010002001120199">
<td class="ColValue" align="center">5</td>
<td class="ColValue" align="center"><a href="DJOutputDetail.jsp?type=9&id=1101010002001120199">1101010009992001120199</a></td>
<td class="ColValue" align="center">朱强</td>
<td class="ColValue" align="center">男</td>
<td class="ColValue" align="center">110105196302192256</td>
<td class="ColValue" align="center">北阳区</td>
<td class="ColValue" align="center">窝、庇案</td>
<td class="ColValue" align="center">北东城区</td>
</tr>><tr align="center" class="evenSelNone" onDblClick="openDetail(this)" onclick="rowSelected(this)" ref="DJOutputDetail.jsp?type=9&id=1101010002004010009">
<td class="ColValue" align="center">9</td>
<td class="ColValue" align="center"><a href="DJOutputDetail.jsp?type=9&id=1101010002004010009">1101010009992004010009</a></td>
<td class="ColValue" align="center">于飞</td>
<td class="ColValue" align="center">男</td>
<td class="ColValue" align="center">211224198408235339</td>
<td class="ColValue" align="center">辽县</td>
<td class="ColValue" align="center">故意伤害案</td>
<td class="ColValue" align="center">北京东城区</td>
</tr><tr align="center" class="evenSelNone" onDblClick="openDetail(this)" onclick="rowSelected(this)" ref="DJOutputDetail.jsp?type=9&id=1101020000000030122">
<td class="ColValue" align="center">14</td>
<td class="ColValue" align="center"><a href="DJOutputDetail.jsp?type=9&id=1101020000000030122">1101020009992008020002</a></td>
<td class="ColValue" align="center">孙浣铭</td>
<td class="ColValue" align="center">男</td>
<td class="ColValue" align="center">220724198901215436</td>
<td class="ColValue" align="center">吉林松原市扶余县</td>
<td class="ColValue" align="center">故意伤害案</td>
<td class="ColValue" align="center">北京西城区</td>
</tr><tr align="center" class="evenSelNone" onDblClick="openDetail(this)" onclick="rowSelected(this)" ref="DJOutputDetail.jsp?type=9&id=1101020002004120145">
<td class="ColValue" align="center">16</td>
<td class="ColValue" align="center"><a href="DJOutputDetail.jsp?type=9&id=1101020002004120145">1101020009992004120145</a></td>
<td class="ColValue" align="center">王光春</td>
<td class="ColValue" align="center">男</td>
<td class="ColValue" align="center">512227197701067879</td>
<td class="ColValue" align="center">重庆巫山县</td>
<td class="ColValue" align="center">抢劫案</td>
<td class="ColValue" align="center">北京西城区</td>
</tr>

</table>
</td>
</tr>
</table>
</td>
</tr><tr>
<td width="100%">
<table width="100%">
<tr>
<td align="left" width="50%">查询结果共302318名/本页为第1页/共16796页&nbsp;(只返回前5000名记录)</td> <td align="right" width="20%">&nbsp;</td>

<td align="right" width="10%">&nbsp;</td>
<td align="right" width="20%">
<a href="DJOutputList.jsp?type=9&show_type=simple&endid=1101020002005060053&firstid=1100000000000014380&intCount=302318&flag=behind&page=2&intperpagecount=18&from_sub=">[下一页]</a>&nbsp;
</td>
</tr>
</table>
</td>
</tr> </table>
</form>
</center>
<script>
function returnquery(type){
window.location.href="DJQuery";
}function SelectAll(obj,num){
if(num!=0){
for (var i=0;i<document.frmQuery.elements.length;i++)
{
var e = document.frmQuery.elements[i];
if(e.name=='checkid')
e.checked = !e.checked;

}
if(obj.value=="选中本页")
obj.value = "清空选择";
else
obj.value = "选中本页";
}
}
</script>
</BODY>
</HTML>

解决方案 »

  1.   

    下一页<tr>
    <td width="100%">
    <table width="100%">
    <tr>
    <td align="left" width="50%">查询结果共302318名/本页为第3页/共16796页&nbsp;(只返回前5000名记录)</td> <td align="right" width="20%">&nbsp;</td>

    <td align="right" width="10%">&nbsp;</td>
    <td align="right" width="20%">
    <a href="DJOutputList.jsp?type=9&show_type=simple&endid=4202060012001080001&firstid=3102260312004090151&intCount=302318&flag=first&page=1&intperpagecount=18&from_sub=">[首页]</a>&nbsp;
    <a href="DJOutputList.jsp?type=9&show_type=simple&endid=4202060012001080001&firstid=3102260312004090151&intCount=302318&flag=behind&page=4&intperpagecount=18&from_sub=">[下一页]</a>&nbsp;
    </td>
    </tr>
    </table>
    </td>
    </tr>
    最后一页
    <tr>
    <td width="100%">
    <table width="100%">
    <tr>
    <td align="left" width="50%">查询结果共302280名/本页为第16794页/共16794页&nbsp;(只返回前5000名记录)</td> <td align="right" width="20%">&nbsp;</td>

    <td align="right" width="10%">&nbsp;</td>
    <td align="right" width="20%">
    <a href="DJOutputList.jsp?type=9&show_type=simple&endid=3101090000000039108&firstid=1101050002001080236&intCount=302280&flag=first&page=1&intperpagecount=16794&from_sub=">[首页]</a>&nbsp;
    </td>
    </tr>
    </table>
    </td>
    </tr> 我已经向  root_提问个这个问题了,可是当时自己对问题不是太清楚,所以问题也不问的不明确现在才清楚我想要的
    上面两楼  分别是首页,下一页(数据和首页数据格式一致,故省略了)和 最后一页(数据和首页数据格式一致,故省略了)
    我需要获得 每页上链接  确切的说是 Body中 Table 的单元格的超链接 如
    <td class="ColValue" align="center"> <a href="DJOutputDetail.jsp?type=9&id=1101010002004010009">1101010009992004010009 </a> </td> 
    <td class="ColValue" align="center">于飞 </td> 
    我只需要得到 DJOutputDetail.jsp?type=9&id=1101010002004010009,
    同时还需要获得本页上[下一页]
    <a href="DJOutputList.jsp?type=9&show_type=simple&endid=3101090000000039108&firstid=1101050002001080236&intCount=302280&flag=first&page=1&intperpagecount=16794&from_sub=">
    中的DJOutputList.jsp?type=9&show_type=simple&endid=3101090000000039108&firstid=1101050002001080236&intCount=302280&flag=first&page=1&intperpagecount=16794&from_sub=
    的链接,来进行递归读取下一页上的链接列表, 这里有一个问题,到最后一页的时候,是返回首页的链接,递归的话 这个如何处理?
      

  2.   

    以下的写法,假定你的数据格式相同,取table中链接时,是根据table中的id="tt"来取的,楼主确认一下是否每一页的table都符合这个条件
    取下一页的链接时,是根据“下一页”这个字符串来取的,所以不存在楼主说的递归到最后一页时又返回首页的情况string html = ...........;//取table中链接
    Match mTable = Regex.Match(html, @"<table[^>]*?id=""tt""[^>]*>[\s\S]*?</table>", RegexOptions.IgnoreCase);
    if (mTable.Success)
    {
        MatchCollection mc = Regex.Matches(mTable.Value, @"<td[^>]*>\s*<a\s*href=""(?<url>[^""]*)""[^>]*>[\s\S]*?</a>\s*</td>", RegexOptions.IgnoreCase);
        foreach (Match m in mc)
        {
            richTextBox1.Text += m.Groups["url"].Value + "\n";
        }
    }
    //取下一页链接
    Match mNext = Regex.Match(html, @"<a\s*href=""(?<next>[^""]*)""[^>]*>[^>]*?下一页[^>]*</a>", RegexOptions.IgnoreCase);
    if (mNext.Success)
    {
        richTextBox1.Text += mNext.Groups["next"].Value + "\n";
    }
    用正则从字符串中提取子字符串,是需要以一些固定的,或是符合一定规律的字符串做为参照物来提取的,所以首先要明确哪些字符串,或是哪些规律是固定的,就像以上两个正则中的id="tt"和“下一页”一样
      

  3.   

    非常感谢  root_的回答
    自己太笨,没什么好说的了,再谢
    完成后过来结贴,真的不能加了  教我下 正则么, 285775860 谢谢
      

  4.   

    分多少不重要,重要是能解决楼主的问题我最近比较忙,除了周末,只能晚上来看看正则学习要多练习才行,要看楼主是否有确实需要了,推荐一篇正则学习的文章吧
    http://www.regexlab.com/zh/regref.htm