//WebClient取网页源码
private string GetHtmlSource(string Url)
{
try
{
System.Net.WebClient wc = new System.Net.WebClient();
wc.Headers["Accept-Language"] = "zh-cn";
wc.Encoding = Encoding.GetEncoding("utf-8"); return wc.DownloadString(Url);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return "";
}
}

除了DownloadString,WebClient还有DownloadFile和DownloadData两个函数。可以下载数据和文件。而DownloadString可以下载uri对应的网页代码。

留文备用。

最新文章

  1. Spark高级数据分析中文版-读者交流
  2. 字符串表达式String Expressions
  3. C:指针、数据类型、格式化输入输出、输入函数的坑点
  4. OCP读书笔记(13) - 管理内存
  5. @+android:id的一些记录
  6. css全局样式表
  7. java类集框架(ArrayList,LinkedList,Vector区别)
  8. 五 : springMVC拦截器
  9. LeetCode算法题-Find Pivot Index(Java实现)
  10. ZabbixServer安装
  11. Visible Lattice Points SPOJ - VLATTICE 三维+莫比乌斯反演
  12. MFC控件编程之鼠标跟键盘消息
  13. [EXP]Joomla! Component Easy Shop 1.2.3 - Local File Inclusion
  14. CentOS下SSH远程免密登录服务器
  15. Js_获取当前日期时间
  16. rabbitmq route
  17. Python入门之logging模块
  18. Python3 集合(set)(十五)
  19. jQuery基础笔记(3)
  20. C和C++中的不定参数

热门文章

  1. tomcat jvm 参数优化
  2. Intellij idea 配置热部署
  3. python dict 和 json 互转
  4. Python把同一个对象循环赋值给另外一个变量
  5. C++ smart pointer智能指针
  6. groupby elasticsearch
  7. 【IOS学习】之四、协议,委托,分类粗解
  8. 使用CountDownTimer实现倒计时功能
  9. js实现默认或者触发一个事件选中元素内容的方法
  10. 【Bayesian】贝叶斯决策方法(Bayesian Decision Method)