gpt4 book ai didi

javascript - xpath 和 html 值 (javascript)

转载 作者:行者123 更新时间:2023-11-28 09:10:58 25 4
gpt4 key购买 nike

假设我想检查“xpath html value”是否等于网站中的某些文本。

喜欢:

html/body/div/div[7]/table/tbody/tr[2]/td value = "some text" 

如何获得它?

最佳答案

您可以使用document.evaluate来执行此操作:

var value = document.evaluate('html/body/div/div[7]/table/tbody/tr[2]/td', document.documentElement, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent;

看看here有关如何设置迭代器并迭代多个节点的更多信息,以防您需要获取 tr 中多个 td 的值.

关于javascript - xpath 和 html 值 (javascript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16331461/

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