Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用BeautifulSoup获取页面中最大行数的表_Python_Beautifulsoup - Fatal编程技术网

Python 使用BeautifulSoup获取页面中最大行数的表

Python 使用BeautifulSoup获取页面中最大行数的表,python,beautifulsoup,Python,Beautifulsoup,有人能告诉我如何在一个HTML页面中获得行数最多的表吗?我用的是BeautifulSoup 不过有一个小问题。有时,似乎有一个表嵌套在另一个表中 <table> <tr> <td> <table> <tr> <td></td> <td><

有人能告诉我如何在一个HTML页面中获得行数最多的表吗?我用的是BeautifulSoup

不过有一个小问题。有时,似乎有一个表嵌套在另一个表中

<table>
    <tr>
        <td>
            <table>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        <td>
    </tr>
</table>
我真的很迷茫。有人帮忙吗


提前感谢

这样计算行数:

number_of_rows = len(table.findAll(lambda tag: tag.name == 'tr' and tag.findParent('table') == table))

你没有可以用来区分表的类或id吗?
number_of_rows = len(table.findAll(lambda tag: tag.name == 'tr' and tag.findParent('table') == table))