/// <summary>
/// 读取url生成静态页
/// </summary>
/// <param name="strUrl">url地址 "http://www.blyyx.com///Default.aspx"</param>
/// <param name="filePath">写文件的地址,没有的话则创建 "../index.html"</param>
/// <returns></returns>
///
public static bool MarkHtml(string strUrl, string filePath)
{
try
{
//创建请求
WebRequest Dd_gUrl = WebRequest.Create(strUrl);
Dd_gUrl.UseDefaultCredentials = false;
WebResponse WebRe = Dd_gUrl.GetResponse();
Stream strhtml = WebRe.GetResponseStream();
StreamReader stRCmcnHtml = new StreamReader(strhtml, Encoding.GetEncoding("utf-8"));
StreamWriter Sw = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath(filePath), false, Encoding.GetEncoding("utf-8")); ;
Sw.Write("<meta charset='utf-8'/>" + stRCmcnHtml.ReadToEnd());//<meta charset="utf-8"/>百度收录不乱码
Sw.Flush();
Sw.Close();
strhtml.Close();
WebRe.Close();
stRCmcnHtml.Close();
return true;
}
catch (Exception ex)
{
throw ex;
}
}
/// 读取url生成静态页
/// </summary>
/// <param name="strUrl">url地址 "http://www.blyyx.com///Default.aspx"</param>
/// <param name="filePath">写文件的地址,没有的话则创建 "../index.html"</param>
/// <returns></returns>
///
public static bool MarkHtml(string strUrl, string filePath)
{
try
{
//创建请求
WebRequest Dd_gUrl = WebRequest.Create(strUrl);
Dd_gUrl.UseDefaultCredentials = false;
WebResponse WebRe = Dd_gUrl.GetResponse();
Stream strhtml = WebRe.GetResponseStream();
StreamReader stRCmcnHtml = new StreamReader(strhtml, Encoding.GetEncoding("utf-8"));
StreamWriter Sw = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath(filePath), false, Encoding.GetEncoding("utf-8")); ;
Sw.Write("<meta charset='utf-8'/>" + stRCmcnHtml.ReadToEnd());//<meta charset="utf-8"/>百度收录不乱码
Sw.Flush();
Sw.Close();
strhtml.Close();
WebRe.Close();
stRCmcnHtml.Close();
return true;
}
catch (Exception ex)
{
throw ex;
}
}