private static string HttpClientRequest(string uri, List<KeyValuePair<string, string>> paramList) { HttpClient httpClient = new HttpClient(); httpClient.MaxResponseContentBufferSize = 256000; httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"); HttpResponseMessage response = httpClient.PostAsync(new Uri(uri), new FormUrlEncodedContent(paramList)).Result; string result = response.Content.ReadAsStringAsync().Result; //用完要记得释放 httpClient.Dispose(); return result; }
时间: 2024-10-06 14:18:05