.net中mshtml處理html的方法
來源:懂視網
責編:小采
時間:2020-11-27 22:41:36
.net中mshtml處理html的方法
.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 do
導讀.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 do

1.添加引用.net 引用Microsoft.mshtml
WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(@"http://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();
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
.net中mshtml處理html的方法
.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 do