ITPub博客

首页 > > > HtmlAgilityPack xpath问题 !!!

HtmlAgilityPack xpath问题 !!!

作者:jenliang 时间:2019-11-07 14:01:08 0 删除 编辑
public static readonly string xpath = "/html/body/div[6]/div[2]/div[1]/ul[1]/li", url = "";

string html = HAPCommon.GetHtmlContentByURL(string.Format("http://{0}/", url));
                HtmlAgilityPack.HtmlDocument htmldoc = new HtmlAgilityPack.HtmlDocument();
          htmldoc.LoadHtml(html);
                
          HtmlNodeCollection nodes = htmldoc.DocumentNode.SelectNodes(xpath);
                //HtmlAgilityPack.HtmlNode xhtml = new HtmlAgilityPack.HtmlNode(HtmlAgilityPack.HtmlNodeType.Element,htmldoc, 0);
                return nodes;

Nodes is  null

 

xpath 是用 Firebug 找到的路径

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4565/viewspace-3118754/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-15

  • 博文量
    189
  • 访问量
    858