本文介绍了如何获取href属性的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在XPath的帮助下,如何在下面的情况下获取href属性的值(只抓取正确的url):
With the help of XPath, how to get the value of the href attribute in the following case (only grabbing the url that is the right one)?:
<a href="http://foo.com">a wrong one</a>
<a href="http://example.com">the right one</a>
<a href="http://boo.com">a wrong one</a>
也就是说,如果链接具有特定文本,则获取 href 属性的值.
That is, to get the value of the href attribute if the link has a particular text.
推荐答案
这将选择属性:
"//a[text()='the right one']/@href"
这篇关于如何获取href属性的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!