c# HttpClient获取网页源码

#region 获取网页源码

public static string HttpClientGetHtmls(string url)
{
try
{
var client = new HttpClient();
var response = client.GetAsync(new Uri(url)).Result;
return response.Content.ReadAsStringAsync().Result;
}
catch (Exception exception)
{
Util.Log(exception);
}
return "";
}
#endregion

posted @ 2017-02-08 13:10  simadi  阅读(1045)  评论(0编辑  收藏  举报