如何使用HTMLAgilityPack获取Link或InnerText

时间:2016-08-03 02:36:25

标签: c# winforms web-crawler html-agility-pack

我有这个结构:

<p class="info">Sample:
    <strong>
       <a href="http://PleaseGetMe.com"target="_blank">http://PleaseGetMe.com</a>
    </strong> 
</p>

我想要的是获得http://PleaseGetMe.com

以下是我的尝试:

                var a = doc.SelectNodes("//*[@class='info']//a");
                Console.WriteLine(a);

哪个不成功。

1 个答案:

答案 0 :(得分:0)

这是我的实施

Set d = .Find(What:=a, After:=ActionCodeCell, LookIn:=xlValues, _ 
LookAt:= xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _ 
MatchCase:=False, SearchFormat:=False)

If d is Nothing Then

    Set d = .Find(What:=b, After:=ActionCodeCell, LookIn:=xlValues, _ 
    LookAt:= xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _ 
    MatchCase:=False, SearchFormat:=False)

End If