gpt4 book ai didi

python - xpath 前同级解决方案

转载 作者:行者123 更新时间:2023-11-30 22:45:46 24 4
gpt4 key购买 nike

enter image description here

现在我需要从<td> 161.5 </td>获取奇数类的内容或只是文本

所以我写道:

element = driver.find_elements_by_xpath('//td[span[@class=" odds-wrap " and @eu="1.90"]]/preceding-sibling::td')

并且它有效。

我的问题是:是否可以使用另一个条件获得相同的内容,例如 title="bet365" .. 因此,我想获得相同的结果,但使用另一个同级元素的另一个条件..

编辑

element = driver.find_elements_by_xpath('//tr[preceding-sibling::td/span[@class=" odds-wrap " and @eu="1.90"] and following-sibling::td/div/a[@title="bet365"]]')
for ele in element:
print(ele.text)

找不到并打印任何内容,我不知道为什么

最佳答案

您可以组合preceding-siblingfollowing-sibling:

//td[following-sibling::td/span[@class=" odds-wrap " and @eu="1.90"] and preceding-sibling::td/a[@title="bet365"]]

关于python - xpath 前同级解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41111435/

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