首页 新闻 会员 周边 捐助

挑战正则获取html信息

0
悬赏园豆:50 [已关闭问题]

<table border=0 width="100%" cellspacing="3" cellpadding="2"
   bgcolor="#FFFFFF">
   
   
   <tr bgcolor="#FFF4D2">
    <td height="15" colspan=3>航程:2008年 12月 10日 武汉
    -- 北京</td>
    <td height="15" colspan=3>
    <div align="center"><b>[ 机票查询结果 ]</b></div>
    </td>
   </tr>
   

   <tr>
    <td colspan=6 height=5
     background="http://www.travelsky.com/travelsky/images/hengxian_s_new.gif"></td>
   </tr>
   
   <tr>
    <td style="height: 23px"><b><font color="CC0000">航班号:</font></b></td>
    <td colspan=2 style="height: 23px"><font color="CC0000">CA1476</font>
      
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="javascript:showETicket();"><font color="#0000FF"><u></u></font></A>
      
      </td>
    <td style="width: 108px; height: 23px"><b><font color="CC0000">机型:</font></b></td>
    <td style="height: 23px"><font color="CC0000">738</font></td>

    <td align="center" style="height: 23px"><u
     onclick="changePRShowtype(this, 'go','0')"
     style="cursor: hand"><img src="http://www.travelsky.com/travelsky/image/airbook/show.gif"
     style='display:none'></u></td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td>中国国际航空公司</td>
    <td align=left>起飞地:<b>武汉天河机场</b> [ 16:00]</td>
    <td>经停</td>
    <td style="width: 108px">头等舱</td>
    <td>公务舱</td>
    <td>经济舱</td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td bgcolor="#FFFFFF"><img
     src='http://www.travelsky.com/travelsky/images/airline/CA.gif'></td>
    <td align=left>到达地:<b>北京首都机场</b> [ 17:55]</td>
    <td>0</td>
    

    <td style="width: 108px">
    <div id="gof0" style="DISPLAY: none"></div>
    <span onmouseover="showCabinInfo(
     'CA1476','F')" onmouseout="hideCabinInfo('CA1476','F')">
     
     1620
     </span>
     </td>
    

 

    
    <td>--</td>
    


    

    <td>
    <div id="goy0" style="DISPLAY: none"> <span
     onmouseover="showCabinInfo(
     'CA1476','Y')" onmouseout="hideCabinInfo('CA1476','Y')">
     
     1080
     </span>
     </div>
    <span onmouseover="showCabinInfo(
     'CA1476','B')" onmouseout="hideCabinInfo('CA1476','B')">
     
     970
     </span>
     </td>
    
   </tr>
   

   <tr>
    <td colspan=6 height=5
     background="http://www.travelsky.com/travelsky/images/hengxian_s_new.gif"></td>
   </tr>
   
   <tr>
    <td><b><font color="CC0000">航班号:</font></b></td>
    <td colspan=2><font color="CC0000">CZ3139</font>
      
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="javascript:showETicket();"><font color="#0000FF"><u></u></font></A>
      
      </td>
    <td style="width: 108px"><b><font color="CC0000">机型:</font></b></td>
    <td><font color="CC0000">738</font></td>

    <td align="center"><u
     onclick="changePRShowtype(this, 'go','1')"
     style="cursor: hand"><img src="http://www.travelsky.com/travelsky/image/airbook/show.gif"
     style='display:none'></u></td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td>中国南方航空公司</td>
    <td align=left>起飞地:<b>武汉天河机场</b> [ 16:00]</td>
    <td>经停</td>
    <td style="width: 108px">头等舱</td>
    <td>公务舱</td>
    <td>经济舱</td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td bgcolor="#FFFFFF"><img
     src='http://www.travelsky.com/travelsky/images/airline/CZ.gif'></td>
    <td align=left>到达地:<b>北京首都机场</b> [ 18:05]</td>
    <td>0</td>
    

    <td style="width: 108px">
    <div id="gof1" style="DISPLAY: none"></div>
    <span onmouseover="showCabinInfo(
     'CZ3139','F')" onmouseout="hideCabinInfo('CZ3139','F')">
     
     1620
     </span>
     </td>
    

 

    
    <td>--</td>
    


    

    <td>
    <div id="goy1" style="DISPLAY: none"> <span
     onmouseover="showCabinInfo(
     'CZ3139','Y')" onmouseout="hideCabinInfo('CZ3139','Y')">
     
     1080
     </span>
      <span
     onmouseover="showCabinInfo(
     'CZ3139','T')" onmouseout="hideCabinInfo('CZ3139','T')">
     
     970
     </span>
     </div>
    <span onmouseover="showCabinInfo(
     'CZ3139','H')" onmouseout="hideCabinInfo('CZ3139','H')">
     
     860
     </span>
     </td>
    
   </tr>
   

   <tr>
    <td colspan=6 height=5
     background="http://www.travelsky.com/travelsky/images/hengxian_s_new.gif"></td>
   </tr>
   <tr>
    <td><b><font color="CC0000">航班号:</font></b></td>
    <td colspan=2><font color="CC0000">MU2455</font>
      
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="javascript:showETicket();"><font color="#0000FF"><u></u></font></A>
      
      </td>
    <td style="width: 108px"><b><font color="CC0000">机型:</font></b></td>
    <td><font color="CC0000">738</font></td>

    <td align="center"><u
     onclick="changePRShowtype(this, 'go','2')"
     style="cursor: hand"><img src="http://www.travelsky.com/travelsky/image/airbook/show.gif"
     style='display:none'></u></td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td>中国东方航空公司</td>
    <td align=left>起飞地:<b>武汉天河机场</b> [ 17:30]</td>
    <td>经停</td>
    <td style="width: 108px">头等舱</td>
    <td>公务舱</td>
    <td>经济舱</td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td bgcolor="#FFFFFF"><img
     src='http://www.travelsky.com/travelsky/images/airline/MU.gif'></td>
    <td align=left>到达地:<b>北京首都机场</b> [ 19:20]</td>
    <td>0</td>
    

    <td style="width: 108px">
    <div id="gof2" style="DISPLAY: none"></div>
    <span onmouseover="showCabinInfo(
     'MU2455','F')" onmouseout="hideCabinInfo('MU2455','F')">
     
     1620
     </span>
     </td>
    

 

    
    <td>--</td>
    


    

    <td>
    <div id="goy2" style="DISPLAY: none"> <span
     onmouseover="showCabinInfo(
     'MU2455','Y')" onmouseout="hideCabinInfo('MU2455','Y')">
     
     1080
     </span>
      <span
     onmouseover="showCabinInfo(
     'MU2455','B')" onmouseout="hideCabinInfo('MU2455','B')">
     
     970
     </span>
     </div>
    <span onmouseover="showCabinInfo(
     'MU2455','H')" onmouseout="hideCabinInfo('MU2455','H')">
     
     860
     </span>
     </td>
    
   </tr>
   

   <tr>
    <td colspan=6 height=5
     background="http://www.travelsky.com/travelsky/images/hengxian_s_new.gif"></td>
   </tr>
   <tr>
    <td><b><font color="CC0000">航班号:</font></b></td>
    <td colspan=2><font color="CC0000">CA1366</font>
      
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="javascript:showETicket();"><font color="#0000FF"><u></u></font></A>
      
      </td>
    <td style="width: 108px"><b><font color="CC0000">机型:</font></b></td>
    <td><font color="CC0000">738</font></td>

    <td align="center"><u
     onclick="changePRShowtype(this, 'go','3')"
     style="cursor: hand"><img src="http://www.travelsky.com/travelsky/image/airbook/show.gif"
     style='display:none'></u></td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td>中国国际航空公司</td>
    <td align=left>起飞地:<b>武汉天河机场</b> [ 19:05]</td>
    <td>经停</td>
    <td style="width: 108px">头等舱</td>
    <td>公务舱</td>
    <td>经济舱</td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td bgcolor="#FFFFFF"><img
     src='http://www.travelsky.com/travelsky/images/airline/CA.gif'></td>
    <td align=left>到达地:<b>北京首都机场</b> [ 21:05]</td>
    <td>0</td>
    

    <td style="width: 108px">
    <div id="gof3" style="DISPLAY: none"></div>
    <span onmouseover="showCabinInfo(
     'CA1366','F')" onmouseout="hideCabinInfo('CA1366','F')">
     
     1620
     </span>
     </td>
    

 

    
    <td>--</td>
    


    

    <td>
    <div id="goy3" style="DISPLAY: none"> <span
     onmouseover="showCabinInfo(
     'CA1366','Y')" onmouseout="hideCabinInfo('CA1366','Y')">
     
     1080
     </span>
      <span
     onmouseover="showCabinInfo(
     'CA1366','B')" onmouseout="hideCabinInfo('CA1366','B')">
     
     970
     </span>
      <span
     onmouseover="showCabinInfo(
     'CA1366','M')" onmouseout="hideCabinInfo('CA1366','M')">
     
     920
     </span>
      <span
     onmouseover="showCabinInfo(
     'CA1366','H')" onmouseout="hideCabinInfo('CA1366','H')">
     
     860
     </span>
     <br>
     <span
     onmouseover="showCabinInfo(
     'CA1366','K')" onmouseout="hideCabinInfo('CA1366','K')">
     
     810
     </span>
     </div>
    <span onmouseover="showCabinInfo(
     'CA1366','L')" onmouseout="hideCabinInfo('CA1366','L')">
     
     760
     </span>
     </td>
    
   </tr>
   

   <tr>
    <td colspan=6 height=5
     background="http://www.travelsky.com/travelsky/images/hengxian_s_new.gif"></td>
   </tr>
   <tr>
    <td><b><font color="CC0000">航班号:</font></b></td>
    <td colspan=2><font color="CC0000">CZ6585</font>
      
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="javascript:showETicket();"><font color="#0000FF"><u></u></font></A>
      
      </td>
    <td style="width: 108px"><b><font color="CC0000">机型:</font></b></td>
    <td><font color="CC0000">73G</font></td>

    <td align="center"><u
     onclick="changePRShowtype(this, 'go','4')"
     style="cursor: hand"><img src="http://www.travelsky.com/travelsky/image/airbook/show.gif"
     style='display:none'></u></td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td>中国南方航空公司</td>
    <td align=left>起飞地:<b>武汉天河机场</b> [ 19:30]</td>
    <td>经停</td>
    <td style="width: 108px">头等舱</td>
    <td>公务舱</td>
    <td>经济舱</td>
   </tr>
   <tr bgcolor="#EFEFEF" align=center>
    <td bgcolor="#FFFFFF" style="height: 65px"><img
     src='http://www.travelsky.com/travelsky/images/airline/CZ.gif'></td>
    <td align=left style="height: 65px">到达地:<b>北京首都机场</b> [ 21:20]</td>
    <td style="height: 65px">0</td>
    

    <td style="width: 108px; height: 65px">
    <div id="gof4" style="DISPLAY: none"></div>
    <span onmouseover="showCabinInfo(
     'CZ6585','F')" onmouseout="hideCabinInfo('CZ6585','F')">
     
     1620
     </span>
     </td>
    

 

    
    <td style="height: 65px">--</td>
    


    

    <td style="height: 65px">
    <div id="goy4" style="DISPLAY: none"> <span
     onmouseover="showCabinInfo(
     'CZ6585','Y')" onmouseout="hideCabinInfo('CZ6585','Y')">
     
     1080
     </span>
      <span
     onmouseover="showCabinInfo(
     'CZ6585','T')" onmouseout="hideCabinInfo('CZ6585','T')">
     
     970
     </span>
     </div>
    <span onmouseover="showCabinInfo(
     'CZ6585','H')" onmouseout="hideCabinInfo('CZ6585','H')">
     
     860
     </span>
     </td>
    
   </tr>
   
   <tr>
    <td colspan=6 height=5
     background="http://www.travelsky.com/travelsky/images/hengxian_s_new.gif"></td>
   </tr>
  </table>

 

 

提取td里面信息,谁能帮帮我啊

路人乙的主页 路人乙 | 初学一级 | 园豆:150
提问于:2008-12-11 10:29
< >
分享
其他回答(4)
0

就用Javascript 的dom或将html处理成XML dom解析试试!

GUO Xingwang | 园豆:3885 (老鸟四级) | 2008-12-11 10:45
0

初学,自己写了一个这样的好像还可以,没有考虑性能问题:

 

(?<=(<td[^>]*>)).*?(?=(</td>))

孤剑 | 园豆:328 (菜鸟二级) | 2008-12-11 13:44
0

LZ要取出tb里面的哪些,先找出显示规律来再谈如何写正则,不然只是取出数据怕是没什么意义

推荐一个开源的东东~HtmlAgility,用来解析html dom

wsky | 园豆:558 (小虾三级) | 2008-12-11 14:02
0

Regex.Replace(html, "<[^>]+>", ""); 不是很准确,我也是网上找的

要有好的心情 | 园豆:502 (小虾三级) | 2008-12-11 14:02
0

是取其中的链接?还是全部内容?

上不了岸的鱼 | 园豆:4613 (老鸟四级) | 2008-12-11 15:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册