WebClient webClient;
Uri urimx = new Uri("http://..............");string path2 = @"D:\Text\";
webClient = new WebClient();
webClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于对向Internet资源的请求进行身份验证的网络凭据。 Byte[] pageData = new Byte[] { }; try { pageData = webClient.DownloadData(urimx); //从指定网站下载数据 } catch (Exception) { } finally { webClient.Dispose(); } string pageHtml = Encoding.UTF8.GetString(pageData); //如果获取网站页面采用的是UTF-8,则使用这句 string[] stringSeparators = new string[] { "\r\n" }; string[] arr = pageHtml.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arr.Length; i++) { string txtName = arr[i].Split(',')[0] + ".txt"; StreamWriter writer = null; writer = new StreamWriter(path2 + txtName, true, Encoding.Default); writer.WriteLine(arr[i]); writer.Flush(); writer.Close(); }