string url = "http://";
//创建HttpClient(注意传入HttpClientHandler)
var handler = new HttpClientHandler() { AutomaticDecompression = System.Net.DecompressionMethods.None };//.GZip };
using (var http = new HttpClient(handler))
{
var response = http.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
return response.Content.ReadAsStringAsync().Result.Replace("\"", "");
else
throw new Exception("Error");
}
时间: 2024-10-03 18:55:56