Select only items in a specific DIV using HtmlAgilityPack

前端 未结 1 1277
谎友^
谎友^ 2020-12-06 05:53

I\'m trying to use the HtmlAgilityPack to pull all of the links from a page that are contained within a div declared as

However, w
相关标签:
1条回答
  • 2020-12-06 06:36

    This will work:

    node.SelectNodes("a[@href]")
    

    Also, you can do it in a single selector:

    doc.DocumentNode.SelectSingleNode("//div[@class='content']//a[@href]")
    

    Also, note that link.Value isn't defined for HtmlNode, so your code doesn't compile.

    0 讨论(0)
提交回复
热议问题