好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

.net中mshtml处理html的方法

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();

查看更多关于.net中mshtml处理html的方法的详细内容...

  阅读:52次