How can I find the link URL by link text with XPath?

后端 未结 6 1840
臣服心动
臣服心动 2020-12-04 08:06

I have a well formed XHTML page. I want to find the destination URL of a link when I have the text that is linked.

Example



        
6条回答
  •  心在旅途
    2020-12-04 08:17

    if you are using html agility pack use getattributeValue:

    $doc2.DocumentNode.SelectNodes("//div[@class='className']/div[@class='InternalClass']/a[@class='InternalClass']").GetAttributeValue("href","")
    

提交回复
热议问题