且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用HTMLAGILITY包提取具有特定属性的表格行

更新时间:2023-01-17 18:37:12

The code doc.LoadHtml("http://theurl.com"); will not work. The parameter to LoadHtml should be a string containing HTML, not a URL. You must first fetch the HTML document before trying to parse it.

Once you have the document loaded, for this specific example you can use this:

IEnumerable<string> links = doc.DocumentNode
                               .SelectNodes("//a[@class='tim_new']")
                               .Select(n => n.Attributes["href"].Value);

相关阅读

技术问答最新文章