webbrowser+Nsoup 实现百度文库内容复制 NSoup.Nodes.Document NSoupDoc = NSoup.NSoupClient.Parse(webBrowser1.Document.Body.InnerHtml); var strpagecount = NSoupDoc.Body.Select(".page-count").Text; if (strpagecount.Contains("/")) { strpagecount = strpagecount.Replace("/", ""); } int pagecount = 0; if (!int.TryParse(strpagecount, out pagecount)) { MessageBox.Show("页数处理失败"); return; } StringBuilder content = new StringBuilder(); for (int i = 0; i < pagecount; i++) { content.Append(NSoupDoc.Body.Select("#pageNo-"+(i+1)).Text); }
2022-03-16 16:58:13 100KB webbrowser+Nsoup
1
C#解析html类库NSoup.dll 调用代码如下: string html = "<html><head><title>First!</title></head><body><p title='test'>First post!</body></html>"; Document doc = NSoupClient.Parse(html); NSoup.Select.Elements ele = doc.GetElementsByTag("title"); string title = ""; foreach (var i in ele) { title = i.ToString(); } var Peles= doc.GetElementsByTag("p"); foreach (var item in Peles) { var t = item.Attr("title"); }
2022-01-22 17:13:35 204KB C# NSoup.dll
1
此类库,经本人测试 只有.net3.5可以用 4.0及以下怎么使用不清楚 请其他网友补充 一款强大的html解析库,有着类似于JQuery方法的标签选择函数 适合做网页采集功能用 引用代码简单示例: using NSoup; using NSoup.Nodes; using NSoup.Select; NSoup.Nodes.Document doc = NSoup.NSoupClient.Parse(HtmlString);
2021-02-27 16:06:29 86KB Nsoup jsoup c# .net
1