gpt4 book ai didi

python-3.x - lxml 不支持 xpath 上的多个属性过滤器

转载 作者:行者123 更新时间:2023-12-02 14:14:17 25 4
gpt4 key购买 nike

我想使用xpath选择具有多个属性的节点

有什么办法可以解决我的问题吗?

node.xpath('.//td[@colspan=6 @class="mbw"]')

  File "lxml.etree.pyx", line 1507, in lxml.etree._Element.xpath (src/lxml/lxml.etree.c:52198)
File "xpath.pxi", line 307, in lxml.etree.XPathElementEvaluator.__call__ (src/lxml/lxml.etree.c:152124)
File "xpath.pxi", line 227, in lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:151097)
File "xpath.pxi", line 212, in lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:150896)
lxml.etree.XPathEvalError: Invalid predicate

最佳答案

您的 xpath 表达式缺少用于组合每个属性条件的逻辑运算符(andor),例如:

node.xpath('.//td[@colspan=6 and @class="mbw"]')

关于python-3.x - lxml 不支持 xpath 上的多个属性过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32883217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com