new*_*ike 3 xpath lxml python-3.x
我想使用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
Run Code Online (Sandbox Code Playgroud)
您的xpath表达式缺少用于组合每个属性条件的逻辑运算符(and
或or
),例如:
node.xpath('.//td[@colspan=6 and @class="mbw"]')
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1531 次 |
最近记录: |