/// <summary>
/// 获取网页html源文件
/// </summary>
/// <param name="url">网页地址</param>
/// <param name="encodingStr">网页文件编码字符串</param>
/// <returns>html源文件</returns>
#region GetPageSource
public static string GetPageSource(string url string encodingStr)
{
HttpWebResponse res = null;
string strResult = "";
try
{
HttpWebRequest req = (HttpWebRequest)WebRequestCreate(url);
//reqMethod = "POST";
reqKeepAlive = true;
reqContentType = "application/xwwwformurlencoded";
reqAccept = "text/Htmlapplication/xhtml+XMLapplication/xml;q=*/*;q=";
reqUserAgent = "Mozilla/ (Windows; U; Windows NT ; zhCN; rv:) Gecko/ Firefox/";
res = (HttpWebResponse)reqGetResponse();
StreamReader reader = new StreamReader(resGetResponseStream() EncodingGetEncoding(encodingStr));
strResult = readerReadToEnd();
readerClose();
}
catch
{
}
finally
{
if (res != null)
{
resClose();
}
}
return strResult;
}