Issue with HTMLAgilityPack parsing HTML using C#

前端 未结 3 1592
夕颜
夕颜 2021-01-21 05:54

I\'m just trying to learn about HTMLAgilityPack and XPath, I\'m attempting to get a list of (HTML Links) companies from the NASDAQ website;

http://www.nasdaq.com/quotes/

3条回答
  •  醉梦人生
    2021-01-21 06:39

    Why won't you just use Descendants("a") method? It's much simplier and is more object oriented. You'll just get a bunch of objects. The you can just get the "href" attribute from those objects.

    Sample code:

    htmlDoc.DocumentNode.Descendants("a").Attributes["href"].Value
    

    If you just need list of links from certain webpage, this method will do just fine.

提交回复
热议问题