2024-05-19 00:00:00 发布
网友
我在刮this page
我的选汤器是:
test = soup.select('#bodyContent > #mw-content-text > table.wikitable:nth-of-type(4)')
这将返回#cmw content text的第4个子表。在
但它返回一个空列表。在
但如果我问:
我有同样的选择器。在
我在实现过程中遗漏了什么?在
发生这种情况是因为不能将nth-of-type()与类标记一起使用,它只能用在如下元素的类型上:table:nth-of-type(4)。对于这个特殊的例子
nth-of-type()
table:nth-of-type(4)
不可能,所以您应该使用您在问题中建议的解决方法
另请查看this great question and subsequent answer关于在CSS3中使用:nth-of-type()。在
:nth-of-type()
发生这种情况是因为不能将
nth-of-type()
与类标记一起使用,它只能用在如下元素的类型上:table:nth-of-type(4)
。对于这个特殊的例子不可能,所以您应该使用您在问题中建议的解决方法
^{pr2}$另请查看this great question and subsequent answer关于在CSS3中使用
:nth-of-type()
。在相关问题 更多 >
编程相关推荐