复制代码 代码如下:
using System.Net;
using System.IO;
复制代码 代码如下:
/// <summary>
/// 根据Url获得源文件内容
/// </summary>
/// <param>合法的Url地址</param>
/// <returns></returns>
public static string GetSourceTextByUrl(string url)
{
WebRequest request = WebRequest.Create(url);
request.Timeout = 20000;//20秒超时
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream);
return sr.ReadToEnd();
}
新闻热点
疑难解答
图片精选