【问题标题】:How to get the Link or InnerText using HTMLAgilityPack如何使用 HTMLAgilityPack 获取 Link 或 InnerText
【发布时间】:2016-08-03 02:36:25
【问题描述】:

我有这个结构:

<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);

这不成功。

【问题讨论】:

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


    【解决方案1】:

    这是我的实现

    foreach (HtmlNode node in doc.SelectNodes("//*[@class='info']//a"))
                    {
                        string value = node.InnerText;
                        Console.WriteLine(value);
                    }
    

    【讨论】:

      猜你喜欢
      • 2017-06-17
      • 1970-01-01
      • 2016-06-15
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 2011-03-14
      • 2017-11-25
      • 2013-03-05
      相关资源
      最近更新 更多