Html Agility Pack - Parsing <li>

旧城冷巷雨未停 提交于 2019-11-28 08:15:28

问题


I want to scrape a list of facts from simple website. Each one of the facts is enclosed in a <li> tag. How would I do this using Html Agility Pack? Is there a better approach?

The only things enclosed in <li> tags are the facts and nothing else.


回答1:


Something like:

List<string> facts = new List<string>();
foreach (HtmlNode li in doc.DocumentNode.SelectNodes("//li")) {
    facts.Add(li.InnerText);
}


来源:https://stackoverflow.com/questions/881425/html-agility-pack-parsing-li

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!