surfing
 1 /// <summary>
 2 /// 获取网页源码
 3 /// </summary>
 4 /// <param name="Url">链接</param>
 5 /// <param name="CharSet">编码</param>
 6 /// <returns></returns>
 7 public static string GetSource(string Url, string CharSet = "utf-8")
 8 {
 9     using (WebClient myWebClient = new WebClient())
10     {
11         using (Stream myStream = myWebClient.OpenRead(Url))
12         {
13             using (StreamReader sr = new StreamReader(myStream, System.Text.Encoding.GetEncoding(CharSet)))
14             {
15                 return sr.ReadToEnd();
16             }
17         }
18     }
19 }
View Code

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-27
  • 2021-11-27
  • 2022-02-11
  • 2021-12-28
  • 2021-07-22
  • 2022-03-05
  • 2021-12-14
猜你喜欢
  • 2021-11-26
  • 2021-11-27
  • 2021-11-27
  • 2021-12-28
  • 2021-08-20
  • 2022-12-23
相关资源
相似解决方案