是你写的啊!!!!
你帮我再改进一下啊!现在有的TABLE截不了!你试一下喽!
好人哦

解决方案 »

  1.   

    还有什么table截不了的。我试过都可以啊。你是不是本来table就不成对啊
      

  2.   

    这个是我总结的一个截取带table和img的函数,能帮我完善一下嘛!
    现在遇到复杂的table还是不行的。
    希望高手指点一下!----------------这正则不是我写的吗—_—b-------------
    ......- -b
      

  3.   

    <TABLE cellSpacing=0 cellPadding=0 width=1002 border=0>
    <TBODY>
    <TR>
    <TD>
    <TABLE height=236 width="100%" bgColor=#00626e border=0>
    <TBODY>
    <TR>
    <TD vAlign=top width=250 rowSpan=3>
    <TABLE width="100%" border=0>
    <TBODY>
    <TR>
    <TD><IMG height=72 src="http://blog.sina.com.cn/control/writing/scriber/images/logo.jpg" width=250></IMG></TD></TR>
    <TR>
    <TD>
    <TABLE width="85%" border=0>
    <TBODY>
    <TR>
    <TD bgColor=#ffffff colSpan=3 height=2></TD></TR>
    <TR>
    <TD width=50 height=25></TD>
    <TD>&nbsp;</TD>
    <TD align=right>&nbsp;</TD></TR>
    <TR>
    <TD width=50 height=25></TD>
    <TD><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/blog/index.php">博客园地</A></TD>
    <TD align=right><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/iask/index.php">寻医问药</A></TD></TR>
    <TR>
    <TD width=50 height=25></TD>
    <TD><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=1">人文时事</A></TD>
    <TD align=right><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=2">营养饮食</A></TD></TR>
    <TR>
    <TD width=50 height=25></TD>
    <TD><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=5">母婴园地</A></TD>
    <TD align=right><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=6">健康资讯</A></TD></TR>
    <TR>
    <TD width=50 height=25></TD>
    <TD><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=3">美容健身</A></TD>
    <TD align=right><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=4">心理天地</A></TD></TR>
    <TR>
    <TD width=50 height=25></TD>
    <TD><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=7">就医通道</A></TD>
    <TD align=right><A class=a3 href="http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=8">学习园地</A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
    <TD vAlign=top width=470 rowSpan=3>
    <TABLE width="100%" border=0>
    <TBODY>
    <TR>
    <TD height=40>&nbsp;</TD></TR>
    <TR>
    <TD align=middle><IMG height=58 src="http://blog.sina.com.cn/control/writing/scriber/images/doctor.jpg" width=318></IMG></TD></TR>
    <TR>
    <TD>
    <TABLE width="99%" align=center border=0>
    <TBODY>
    <TR>
    <TD style="LINE-HEIGHT: 150%" align=left>&nbsp;&nbsp;&nbsp;&nbsp;在我<BR><BR></TD></TR></TBODY></TABLE></TD></TR>
    <TR>
    <TD bgColor=#cccccc height=1></TD></TR>
    <TR>
    <TD height=14></TD></TR>
    <TR>
    <TD class=td04 align=middle>&nbsp;&nbsp;<A class=a3 href="http://blog.sina.com/" target=_blank>产品与服务</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A class=a3 href="http://blog.sina.com.cn/control" target=_blank>关于我们</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR></TBODY></TABLE></TD>
    <TD height=40></TD></TR>
    <TR>
    <TD><IMG height=137 src="http://blog.sina.com.cn/control/writing/scriber/images/map.jpg" width=248></IMG></TD></TR>
    <TR>
    <TD align=middle>&nbsp;</TD></TR></TBODY></TABLE></TD></TR>
    <TR>
    <TD background=images/%C3%83%C3%BB%C3%92%C2%BD%C3%8D%C3%B8.jpg height=130></TD></TR>
    <TR>
    <TD>
    <TABLE width="100%" bgColor=#ffffff border=0>
    <TBODY>
    <TR height=5>
    <TD></TD></TR>
    <TR>
    <TD>
    <TABLE width="100%" border=0>
    <TBODY>
    <TR>
    <TD class=td01 width=256>&nbsp;</TD>
    <TD class=td02 align=right width=256>&nbsp;</TD>
    <TD class=td02 align=right colSpan=2>&nbsp;</TD></TR>
    <TR>
    <TD bgColor=#000000 colSpan=2 height=2></TD>
    <TD colSpan=2></TD></TR>
    <TR>
    <TD class=td03 align=middle colSpan=2 height=25 rowSpan=2 HREF="http://blog.sina.com.cn/control/writing.php" TARGET="_blank">忘记密码</TD>
    <TD class=td02 vAlign=bottom align=right width=262 rowSpan=2><A href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202005030200018" target=_blank><IMG height=48 src="http://blog.sina.com.cn/control/writing/scriber/images/biaoshi.gif" width=40 border=0></IMG></A></TD>
    <TD class=td02 align=right width=204 height=25>E-mail: <A class=a04 href="mailto:[email protected]">[email protected]</A></TD></TR>
    <TR>
    <TD class=td02 align=right></TD></TR>
    <TR>
    <TD>
    <FORM action=./modules/index_userlogin.php method=post>&nbsp;&nbsp;&nbsp;&nbsp;健康会员&nbsp;<INPUT id=username style="HEIGHT: 12px" size=18 name=username></INPUT> &nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;码&nbsp;<INPUT id=password style="HEIGHT: 12px" type=password size=18 name=password></INPUT> &nbsp;&nbsp;&nbsp;&nbsp;<INPUT style="FONT-SIZE: 12px" type=submit value=登录></INPUT> <INPUT type=hidden value=normal name=usertype></INPUT> <INPUT type=hidden value=login name=act></INPUT></FORM></TD>
    <TD class=td02 align=right colSpan=2 height=25></TD></TR>
    <TR>
    <TD class=td02 align=right colSpan=2 height=25></TD></TR>
    <TR>
    <TD>
    <FORM action=./modules/index_userlogin.php method=post>&nbsp;&nbsp;&nbsp;&nbsp;医生会员&nbsp;<INPUT id=username style="HEIGHT: 12px" size=18 name=username></INPUT> &nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;码&nbsp;<INPUT id=password style="HEIGHT: 12px" type=password size=18 name=password></INPUT> &nbsp;&nbsp;&nbsp;&nbsp;<INPUT style="FONT-SIZE: 12px" type=submit value=登录></INPUT> <INPUT type=hidden value=doctor name=usertype></INPUT> <INPUT type=hidden value=login name=act></INPUT></FORM></TD>
    <TD class=td02 align=right colSpan=2></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
    <DIV></DIV>
      

  4.   

    把这段截了你看应该如何写,下面是新浪BLOG截取的XML!
      

  5.   

    <title>sdfsfsdf</title> 
      <link>http://blog.sina.com.cn/u/553c6d60010004fo</link> 
      <description><?xml version="1.0" encoding="gbk"?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <table cellspacing="0" cellpadding="0" width="1002" border="0"> <tbody> <tr> <td> <table height="236" width="100%" bgcolor="#00626E" border="0"> <tbody> <tr> <td valign="top" width="250" rowspan="3"> <table width="100%" border="0"> <tbody> <tr> <td><img height="72" src= "http://blog.sina.com.cn/control/writing/scriber/images/logo.jpg" width="250" /></td> </tr> <tr> <td> <table width="85%" border="0"> <tbody> <tr> <td bgcolor="#FFFFFF" colspan="3" height="2"></td> </tr> <tr> <td width="50" height="25"></td> <td>&nbsp;</td> <td align="right">&nbsp;</td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/blog/index.php">博客园地</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/iask/index.php">寻医问药</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=1"> 人文时事</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=2"> 营养饮食</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=5"> 母婴园地</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=6"> 健康资讯</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=3"> 美容健身</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=4"> 心理天地</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=7"> 就医通道</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?"> </a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <br /><br /><a href="/u/553c6d60010004fo" style="font-style: italic;" target="_blank">点击此处查看原文</a></description> 
      

  6.   

    "#(?=(<table(?:(?:[^<]|<(?!table))*?|(?1))*</table>))#is我原来的正则是这样写的。你似乎漏掉了后面的is吧
      

  7.   

    新浪的我测了一共4个table根本没问题呀。
      

  8.   

    Array
    (
        [0] => Array
            (
                [0] => Array
                    (
                        [0] => 
                        [1] => 2
                    )            [1] => Array
                    (
                        [0] => 
                        [1] => 76
                    )            [2] => Array
                    (
                        [0] => 
                        [1] => 182
                    )            [3] => Array
                    (
                        [0] => 
                        [1] => 351
                    )            [4] => Array
                    (
                        [0] => 
                        [1] => 2016
                    )            [5] => Array
                    (
                        [0] => 
                        [1] => 2236
                    )            [6] => Array
                    (
                        [0] => 
                        [1] => 3074
                    )            [7] => Array
                    (
                        [0] => 
                        [1] => 3167
                    )        )
    )
      

  9.   

    preg_match_all("#(?=(<table(?:(?:[^<]|<(?!table))*?|(?1))*</table>))#",$content,$ar,PREG_OFFSET_CAPTURE
    );
    print_r($ar);
      

  10.   

    不是说你漏掉了is吗preg_match_all("#(?=(<table(?:(?:[^<]|<(?!table))*?|(?1))*</table>))#is",$content,$ar,PREG_OFFSET_CAPTURE
    );
    print_r($ar);
      

  11.   

    我添上了也是这样!Gdj!还是不行的
      

  12.   

    你能把MSN或者QQ或邮箱给我吗?我把测试的那个文件给你!方便沟通
      

  13.   

    第一段载出来8个table,根本没错。0到7不是8个是什么……
      

  14.   

    那你指点一下?我该怎么个取法?
    能达到这个效果?
    <table cellspacing="0" cellpadding="0" width="1002" border="0"> <tbody> <tr> <td> <table height="236" width="100%" bgcolor="#00626E" border="0"> <tbody> <tr> <td valign="top" width="250" rowspan="3"> <table width="100%" border="0"> <tbody> <tr> <td><img height="72" src= "http://blog.sina.com.cn/control/writing/scriber/images/logo.jpg" width="250" /></td> </tr> <tr> <td> <table width="85%" border="0"> <tbody> <tr> <td bgcolor="#FFFFFF" colspan="3" height="2"></td> </tr> <tr> <td width="50" height="25"></td> <td>&nbsp;</td> <td align="right">&nbsp;</td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/blog/index.php">博客园地</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/iask/index.php">寻医问药</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=1"> 人文时事</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=2"> 营养饮食</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=5"> 母婴园地</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=6"> 健康资讯</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=3"> 美容健身</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=4"> 心理天地</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=7"> 就医通道</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?"> </a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <br /><br /><a href="/u/553c6d60010004fo" style="font-style: italic;" target="_blank">点击此处查看原文</a>
      

  15.   

    不明白你的意思。上面的例子已经取出8个这样的效果的table了。
      

  16.   

    preg_match_all("#(?=(<table(?:(?:[^<]|<(?!table))*?|(?1))*</table>))#is",$content,$ar);
    print_r($ar);你是不是指的这个?
      

  17.   

    象我帖的那个函数一样,我想把我想要的长度和内容带进去。
    我就想要出最接近我的那个完整的TABLE!
    而且之前如果有字啊,一些别的东西也需要要着,前面的TABLE如果没截全在后面还要补全代码!
      

  18.   

    ……既然8个table都截出来了,哪一个是你要的你比较一下不就知道了吗。我又怎么可以预知到你想要的是哪一个呢?
      

  19.   

    这个我可以比较,可是对于别的文章我哪里知道格式啊!
    我要的是下面的格式,可是八个里面都有,这个给后面的代码补全了
    <table cellspacing="0" cellpadding="0" width="1002" border="0"> <tbody> <tr> <td> <table height="236" width="100%" bgcolor="#00626E" border="0"> <tbody> <tr> <td valign="top" width="250" rowspan="3"> <table width="100%" border="0"> <tbody> <tr> <td><img height="72" src= "http://blog.sina.com.cn/control/writing/scriber/images/logo.jpg" width="250" /></td> </tr> <tr> <td> <table width="85%" border="0"> <tbody> <tr> <td bgcolor="#FFFFFF" colspan="3" height="2"></td> </tr> <tr> <td width="50" height="25"></td> <td>&nbsp;</td> <td align="right">&nbsp;</td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/blog/index.php">博客园地</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/iask/index.php">寻医问药</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=1"> 人文时事</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=2"> 营养饮食</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=5"> 母婴园地</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=6"> 健康资讯</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=3"> 美容健身</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=4"> 心理天地</a></td> </tr> <tr> <td width="50" height="25"></td> <td><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?moduleid=7"> 就医通道</a></td> <td align="right"><a class="a3" href= "http://blog.sina.com.cn/control/writing/scriber/modules/index.php?"> </a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <br /><br /><a href="/u/553c6d60010004fo" style="font-style: italic;" target="_blank">点击此处查看原文</a>