时间:2021-07-01 10:21:17 帮助过:6人阅读
1.添加引用.net 引用Microsoft.mshtml
WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(@"//www.gxlcms.com/web/73969.html");
HTMLDocumentClass doc = new HTMLDocumentClass();//获取html对象
doc.designMode = "on"; //不让解析引擎去尝试运行javascript
doc.IHTMLDocument2_write(str);把html 文档写入html对象中
doc.close();关闭写流
Console.WriteLine(doc.title);输出标题
Console.WriteLine(doc.body.innerText); 输出body
Console.ReadKey();