c#不使用 webBrowser 控件, 在后台加载html流

        private void button1_Click(object sender, EventArgs e)
{
string urlPath = "https://www.cnblogs.com";//
HtmlDocument html = GetHtmlDocument(urlPath);
textBox1.Text = html.Body.InnerHtml;
} //不使用控件中加载html文档
private HtmlDocument GetHtmlDocument(string htmlpath)
{
WebBrowser getInfoWebBrowser = new WebBrowser();
//是否弹出js出错对话框 true 标示不弹对话框
getInfoWebBrowser.ScriptErrorsSuppressed = true;
//把从网络下载的html流赋值给 WebBrowser
/*
* WebRequest.Create(htmlpath).GetResponse().GetResponseStream();
* 从指定网址下载资源
*
*/
getInfoWebBrowser.DocumentStream = WebRequest.Create(htmlpath).GetResponse().GetResponseStream();
HtmlDocument html = getInfoWebBrowser.Document;
//让程序处理当前消息 [不可少]
Application.DoEvents();
//释放资源
getInfoWebBrowser.Dispose();
return html;
}

最新文章

  1. AFNetwork ATS 网络层改造
  2. <实训|第五天>通过搭建NFS,FTP实现共享文件附Vim脚本游戏
  3. PLSQL开发笔记和小结(转载)
  4. codeforces 489C.Given Length and Sum of Digits... 解题报告
  5. Visual Studio 2012 使用免费的Team Foundation Service
  6. redis 订阅与发布
  7. 匹配替换第n个字符串
  8. Linux入门(11)——Ubuntu16.04安装texlive2016并配置texmaker和sublime text3
  9. HDU 6121 Build a tree(找规律+模拟)
  10. 正确使用volatile场景--状态标志
  11. SSM整合(2): spring 与 mybatis 整合
  12. post请求(headers里有属性)报错:Request header field xxx is not allowed by Access-Control-Allow-Headers in preflight response
  13. The Activities of September
  14. Storm实现实时大数据分析
  15. [BZOJ5109]大吉大利,晚上吃鸡!
  16. vim选择命令
  17. 偏前端 + rsa加解密 + jsencrypt.min.js--(新增超长字符分段加解密)
  18. centos 查看mysql数据库命令
  19. React 常用面试题目与分析
  20. R语言初识

热门文章

  1. SpringCloud-Config通过Java访问URL对敏感词加密解密
  2. spark 常用函数介绍(python)
  3. Flutter常见数据类型及数据类型转换
  4. [Ubuntu]18安装navicat 破解版&官方版本
  5. 一百零二:CMS系统之sweetalert提示框和使用
  6. selenium 2019 笔记
  7. CentOS7出现Unit iptables.service could not be found
  8. Python之Numpy:二元函数绘制/三维数据可视化/3D
  9. Mac运行React Native安卓项目报错解决
  10. SQL SERVER CLR Trigger功能