.net中mshtml處理html的方法
來(lái)源:懂視網(wǎng)
責(zé)編:小采
時(shí)間: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
導(dǎo)讀.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對(duì)象
doc.designMode = "on"; //不讓解析引擎去嘗試運(yùn)行javascript
doc.IHTMLDocument2_write(str);把html 文檔寫入html對(duì)象中
doc.close();關(guān)閉寫流
Console.WriteLine(doc.title);輸出標(biāo)題
Console.WriteLine(doc.body.innerText); 輸出body
Console.ReadKey();
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。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