1.添加引用.net 引用Microsoft.mshtml
WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(@"https://www.jb51.net/web/73969.html");
HTMLDocumentClass doc = new HTMLDocumentClass();//獲取html對象
doc.designMode = "on"; //不讓解析引擎去嘗試運行javascript
doc.IHTMLDocument2_write(str);把html 文檔寫入html對象中
doc.close();關(guān)閉寫流
Console.WriteLine(doc.title);輸出標(biāo)題
Console.WriteLine(doc.body.innerText); 輸出body
Console.ReadKey();
標(biāo)簽:海南 臺州 淄博 揚州 嘉興 南昌 南京 南京
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《.net中mshtml處理html的方法》,本文關(guān)鍵詞 .net,中,mshtml,處理,html,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。