mshtml处理html .net中mshtml处理html的方法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

mshtml处理html .net中mshtml处理html的方法

  2021-03-18 我要评论
想了解.net中mshtml处理html的方法的相关内容吗,在本文为您仔细讲解mshtml处理html的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:mshtml,html,下面大家一起来学习吧。

1.添加引用.net 引用Microsoft.mshtml

WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(@"//www.qb5200.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();

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们