gpt4 book ai didi

xpath - xpath-按ID导入div

转载 作者:行者123 更新时间:2023-12-03 16:51:47 25 4
gpt4 key购买 nike

使用Google电子表格中的importxml / xpath,我可以导入具有特定ID的html span元素:

=importxml("https://stackoverflow.com"; "//span[@id='svnrev']")


查找具有特定ID的 div的xpath代码是什么?我试过了:

=importxml("https://stackoverflow.com"; "//div[@id='interestingTags']")
=importxml("https://stackoverflow.com"; "//div[@id='interestingTags']/a")
=importxml("https://stackoverflow.com"; "//*[@id='interestingTags']")


但是我总是收到一个错误(导入为空)。那就是我要导入的HTML:

<div id="interestingTags"><a href="/questions/tagged/adwords-script" class="post-tag" title="show questions tagged &#39;adwords-script&#39;" rel="tag">adwords-script</a> </div>
<span id="svnrev">rev 2017.8.31.26908</span>


更新:我想看到的结果是

<a href="/questions/tagged/adwords-script" class="post-tag" title="show questions tagged &#39;adwords-script&#39;" rel="tag">adwords-script</a> 


...或只是: adwords-script

最佳答案

尝试:-

//span[@id='svnrev' and contains(.,'rev')] -> It will return span




 //div[@id='interestingTags']/a[@class='post-tag' and @rel='tag'] -> it will return a


希望它能对您有所帮助:)

关于xpath - xpath-按ID导入div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45984577/

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