Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.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 “有没有办法拉?”;tr数据索引“;网页抓取的元素?_Python_Web Scraping - Fatal编程技术网

Python “有没有办法拉?”;tr数据索引“;网页抓取的元素?

Python “有没有办法拉?”;tr数据索引“;网页抓取的元素?,python,web-scraping,Python,Web Scraping,我对这一点非常陌生,并试图用以下结构刮取一个网页: <tbody> <tr data-index="0"> #rowelements </tr> <tr data-index="1"> #rowelements </tr> <tr data-index="2"> #rowelements <

我对这一点非常陌生,并试图用以下结构刮取一个网页:

<tbody>
    <tr data-index="0">
    #rowelements
    </tr>
    <tr data-index="1">
    #rowelements
    </tr>
    <tr data-index="2">
    #rowelements
    </tr>
</tbody>
甚至
tbody.findAll(“tr”,{“数据索引”:“0”})
至少返回第一行:

>tbody.findAll(“tr”,{“数据索引”:“0”})
[
#行元素
]
如果您甚至没有得到1个结果,那么您的
t正文
不包含上面显示的内容。请尝试
打印(t车身)
以检查该问题

无论如何,要获取所有行,请使用
tbody.findAll(“tr”,{“数据索引”:True})

>>tbody.findAll(“tr”,{“数据索引”:True})
[
#行元素
, 
#行元素
, 
#行元素
]
>>>蓝
3.
row=tbody.findAll("tr",{"data-index":"0"})
print(row)