gpt4 book ai didi

python - 不是有效的 XPath 表达式

转载 作者:太空宇宙 更新时间:2023-11-04 11:09:37 24 4
gpt4 key购买 nike

我在运行程序时遇到错误,如果我在 chropath 中检查我的 xpath,它不会给出路径错误,但在运行时我遇到错误“有效的 XPath 表达式。”

<article xpath="1">
<div class="imagen">
<img src="https://image.tmdb.org/t/p/w154/bhgCVGl6BDXS8BfcUGzWU5EWnMb.jpg">
<div id="c28153" data-nonce="9f7f7584d7" data-id="28153" data-type="movie" class="cimport">

</div>
</div>
<div class="data">
<h3>It's Alive</h3>
<span>1974</span>
</div>
</article>

Python 代码:

driver.find_element_by_xpath('//h3[translate(. ," - ; : ! , . * ? / \' " , " " )='its live']//preceding::img[1]//following::div[1]').click()

最佳答案

你需要使用:

driver.find_element_by_xpath('//h3[translate(. ," - ; : ! , . * ? / \' " , " " )=\'its live\']//preceding::img[1]//following::div[1]').click()

只需在内部 ' 之前添加 \

关于python - 不是有效的 XPath 表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58627773/

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