当前位置:首页 > Windows程序 > 正文

C#控制台 webcllient下载一个网页的源代码

2021-03-12 Windows程序

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Net; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace ConsoleApplication7 9 { 10 class Program 11 { 12 static void Main(string[] args) 13 { 14 WebClient webC = new WebClient(); 15 string webAdress = @""; 16 string webContent = webC.DownloadString(webAdress); 17 Console.WriteLine(webContent); 18 Console.ReadKey(); 19 } 20 } 21 }

2 效果

技术分享

乱码了。。。为什么呢?编码格式!

我们查看博客园首页的编码格式

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/59747.html