?规?1锛??
///???<summary?>?
///???浼???RL杩???缃?椤电??html浠g???
///???</summary?>?
///???<param???name="Url"?>URL?</param?>?
///???<returns?>?</returns?>?
public ??? static ????? string ???getUrltoHtml( string ???Url)?
... {?
errorMsg???=???"";?
try?
...{?
System.Net.WebRequest???wReq???=???System.Net.WebRequest.Create(Url);?
//???Get???the???response???instance.?
System.Net.WebResponse???wResp???=wReq.GetResponse();?
//???Read???an???HTTP-specific???property?
//if???(wResp.GetType()???==HttpWebResponse)?
//{?
//DateTime???updated?????=((System.Net.HttpWebResponse)wResp).LastModified;?
//}?
//???Get???the???response???stream.?
System.IO.Stream???respStream?????=???wResp.GetResponseStream();?
//???Dim???reader???As???StreamReader???=???New???StreamReader(respStream)?
System.IO.StreamReader???reader???=???new???System.IO.StreamReader(respStream,???System.Text.Encoding.GetEncoding("gb2312"));?
return?????reader.ReadToEnd();?
}?
catch(System.Exception???ex)?
...{?
errorMsg???=???ex.Message???;?
}?
return???"";?
} ?
浣???浠ョ?ㄨ?涓??芥?拌?峰??缃?椤电??瀹㈡?风????html浠g??锛??跺??淇?瀛???html??浠堕??灏卞??浠ヤ????
?规?2锛??
??????涓???????椤甸??????剧?癸??剧??????涓?????椤甸?㈤?寸???宠?????炬?ュ?浣?淇???瀹??达??
?瑰?????ㄩ〉?㈤?绻??存?般??淇??广???????ょ?????典?锛??
???块??宸村反??椤甸????ㄩ?ㄦ??html??锛?浼拌?$?ㄧ?????板????灏??????铰?
?充??板????灏???????锛?http: // www.easewe.com/Article/ShowArticle.aspx?article=131?
??浠ョ????杩?涓?椤甸???????涓?涓?浠?????绔?浠峰??璁℃?垛?????铰?
http: // info.china.alibaba.com/news/subject/v1-s5011580.html?head=top4&Bidding=home5?
ASP.Net????????HTML椤德?
??sp涓?瀹??扮??????????椤电?ㄥ?扮??FileSystemObject瀵硅薄 ! ?
??Net涓?娑???姝ょ被??浣?????System.IO???
浠ヤ???绋?搴?浠g?????娉?姝や唬???????? ! ??????浜轰唬???
????CODE:???????
// ????HTML椤德?
???? public ??? static ??? bool ???WriteFile( string ???strText, string ???strContent, string ???strAuthor)???
???? ... {?
??????string???path???=???HttpContext.Current.Server.MapPath("/news/");?
??????Encoding???code???=???Encoding.GetEncoding("gb2312");?
??????//???璇诲??妯℃?挎??浠堵?
??????string???temp???=???HttpContext.Current.Server.MapPath("/news/text.html");?
??????StreamReader???sr=null;?
??????StreamWriter???sw=null;?
??????string???str="";?????
??????try?
??????...{?
????????sr???=???new???StreamReader(temp,???code);?
????????str???=???sr.ReadToEnd();???//???璇诲????浠堵?
??????}?
??????catch(Exception???exp)?
??????...{?
????????HttpContext.Current.Response.Write(exp.Message);?
????????HttpContext.Current.Response.End();?
????????sr.Close();?
??????}?
????
??????
??????string???htmlfilename=DateTime.Now.ToString("yyyyMMddHHmmss")+".html";?
??????//????挎?㈠??瀹孤?
??????//???杩???妯℃?挎??浠跺凡缁?璇诲?ュ?板??绉颁负str??????涓?浜??
??????str???=str.Replace("ShowArticle",strText);???//妯℃?块〉涓???ShowArticle?
??????str???=???str.Replace("biaoti",strText);?
??????str???=???str.Replace("content",strContent);?
??????str???=???str.Replace("author",strAuthor);?
??????//???????浠堵?
??????try?
??????...{?
????????sw???=???new???StreamWriter(path???+???htmlfilename???,???false,???code);?
????????sw.Write(str);?
????????sw.Flush();?
??????}?
??????catch(Exception???ex)?
??????...{?
????????HttpContext.Current.Response.Write(ex.Message);?
????????HttpContext.Current.Response.End();?
??????}?
??????finally?
??????...{?
????????sw.Close();?
??????}?
??????return???true;?
姝ゅ?芥?版?惧??onn.CS?虹被涓?浜??
?ㄦ坊???伴?荤??浠g??涓?寮??????娉??宸ョ???涓?over?
????????if(Hover.Conn.WriteFilethis.Title.Text.ToString),this.Content.Text.ToString),this.Author.Text.ToString)))?
????????...{?
??????????Response.Write("娣诲??????");?
????????}?
????????else?
????????...{?
??????????Response.Write("????HTML?洪??!");?
????????}???
??
妯℃?块〉Text.html浠g???
????CODE:???????
<!DOCTYPE???HTML???PUBLIC???"-//W3C//DTD???HTML???4.0???Transitional//EN"???>?
<HTML?>?
<HEAD?>?
????<title?>ShowArticle?</title?>?
??????<body?>?
biaoti?
<br?>?
content?<br?>?
author?
</body?>?
</HTML?>?
biaoti?
<br?>?
content?<br?>?
author?
</body?>?
</HTML?>???
??
??绀烘坊????????浼??轰互褰????堕?翠负??浠跺????html??浠?涓??㈠??????浼???杩??ョ????涓????扮?存?ュ???ヤ?HTML??浠朵腑,?ㄥ????搴??ㄤ腑??瑕???娣诲???版??搴?锛??跺????????TML??浠堵?
?规?3锛??
缁?涓?涓?瀹㈡?风????????渚?瀛?锛?SJ锛??
瀹???浣??ㄥ?ㄤ?浠ュ?㈡?风?????瑰??峰????涓?椤甸?㈢??浠g??锛??跺????浠ュ??涓哄?朵??ㄩ??锛???渚????存?ヨ??郝?
<script?>?
????????var???oXmlHttp???=???new???ActiveXObject("Microsoft.XMLHTTP");?
????????oXmlHttp.open("GET","http://www.163.com",???false);?
????????oXmlHttp.send()?
????????var???oStream???=???new???ActiveXObject("ADODB.Stream");?
????????if(oStream???==???null)?
????????????????alert("?ㄧ???哄?ㄤ?????ADODB.Stream.")?
????????else?
????????...{?
????????????????oStream.Type=1;?
????????????????oStream.Mode=3;?
????????????????oStream.Open()???;?
????????????????oStream.Write(oXmlHttp.responseBody);?
????????????????oStream.Position=???0;?
????????????????oStream.Type=???2;?
????????????????oStream.Charset="gb2312";?
????????????????var???result=???oStream.ReadText();?
????????????????oStream.Close();?
????????????????oStream???=???null;?
????var???aa???=???window.open("","")?
????document.write(result);?
????????????????aa.document.write(result);?
????????}?
</script?>?
?规?4锛?瀛?sdn涓??枫????ml淇?瀛??版??锛?妯$??XSL涔?????涓?涓???浠躲???
浣跨??ml?ヤ?瀛??版??锛?浣跨??sl?ュ??涔?妯℃?垮苟涓???绉版?版??????浠ラ??杩?xsl?ュ??逛究???ㄥ?㈡?风?????????℃?垫?剧ず?版????濡???瑕??????????堕?㈤?f?寸????浜????绘?ヤ?涓?.net??xml绫诲????棰?瑙e?炽???
????????????????????????浼??癸???浠ユ?逛究蹇???杞??㈡??浣??宠????煎?????瀹广???
????????????????????????缂虹?癸???瑕?瀛???村?????瀹癸?涓?濂藉?ラ?ㄣ???
?规?5锛??
??璺????
????1.????╃?ㄥ?Dw-Mx杩??风??宸ュ?风????html?煎???妯℃?匡??ㄩ??瑕?娣诲???煎????版?瑰???ョ?规????璁?濡?$htmlformat$),?ㄦ????????浠舵?跺?╃?ㄤ唬??璇诲??姝ゆā?匡??跺???峰????拌??ョ????瀹癸?娣诲???版?ゆā?跨????璁颁?缃?涓?锛??????版??浠跺???????ョ???锛????ュ???????版??搴?涓????ョ?稿?虫?版?????
??????????????2.???浣跨?ㄥ???颁唬??纭?缂???Html??浠讹???浠ヤ娇??tmlTextWriter绫绘?ュ??html??浠躲?????
浼??孤???
????1.?????浠ュ缓绔???甯稿?????椤甸????╃?ㄥ????js??浠剁???规?锛???s??浠跺??????ocument.write()?规???浠ュ?ㄦ????椤甸?㈠?????ュ?椤甸?㈠ご锛?骞垮??绛???瀹广?????
????2.???????html??浠跺?╃??S???Windows2000??Index???Server??浠ュ缓绔??ㄦ????绱㈠???锛??╃??sp.net??浠ヤ互DataTable???瑰?寰??版??绱㈢???????Win2000??Index???℃??娉??ユ??ml??浠剁????瀹广??濡???????浜??版??搴???绱??Index绱㈠??????ユ?撅??d?姝ゆ??绱㈠???藉???甯稿己澶с?????
????3.??????????″?ㄧ??璐??凤?璇锋?涓?涓???????html??浠舵??涓?涓?aspx??浠舵???″?ㄨ?婧?????璁稿??????
????缂虹?孤???
??????璺?浜?锛????濡????ㄧ‖缂??????瑰?锛?宸ヤ?????甯稿ぇ锛???瑕???甯稿???html浠g????璋?璇??伴?俱????涓?浣跨?ㄧ‖缂?????????html?峰???娉?淇??癸?濡???缃?绔??存?㈡?峰?锛??d?蹇?椤诲????扮???锛?缁?????甯??ュ法澶х??宸ヤ????????
??????姝よ??????ㄧ????绗?涓?绉???璺????
????绀哄??浠g?????
????1.瀹?涔?(template.htm)html妯℃?块〉?⒙???
????锛?html锛????
????锛?head锛????
????锛?title锛?锛?/title锛????
????锛?meta???http-equiv="Content-Type"???content="text/html;???charset=gb2312"锛????
????锛?/head锛????
????锛?body???锛????
????锛?table???$htmlformat[0]???height="100%"???border="0"???width="100%"???cellpadding="10"???cellspacing="0"???bgcolor="#eeeeee"???style="border:1px???solid???#000000"锛????
????锛?tr锛????
????锛?td???width="100%"???valign="middle"???align="left"锛????
????锛?span???style="color:???$htmlformat[1];font-size:???$htmlformat[2]"锛?$htmlformat[3]锛?/span锛????
????锛?/td锛????
????锛?/tr锛????
????锛?/table锛????
????锛?/body锛????
????锛?/html锛????
????2.asp.net浠g??锛????
????//---------------------璇?tml妯℃?块〉?㈠??tringbuilder瀵硅薄??----???
????string[]???format=new???string[4];//瀹?涔???htmlyem??璁版?扮??涓??寸???扮????
????StringBuilder???htmltext=new???StringBuilder();???
????try???
????...{???
??????using???(StreamReader???sr???=???new???StreamReader("瀛??炬ā?块〉?㈢??璺?寰???椤甸?㈠??"))???
??????...{???
????String???line;???
????while???((line???=???sr.ReadLine())???!=???null)???
????...{???
??????htmltext.Append(line);???
????}???
????sr.Close();???
??????}???
????}???
????catch???
????...{???
??????Response.Write("锛?Script锛?alert(?"璇诲????浠堕??璇??")锛?/Script锛?");???
????}???
????//---------------------缁???璁版?扮?璧???-----------???
????format[0]="background="bg.jpg"";//?????剧?????
????format[1]=???"#990099";//瀛?浣?棰??猜???
????format[2]="150px";//瀛?浣?澶у????
????format[3]=???"锛?marquee锛???????妯℃??tml椤甸???/marquee锛?";//??瀛?璇存?????
????//----------?挎??tm??????璁颁负浣??冲??????瀹孤???
????for(int???i=0;i锛?4;i++)???
????...{???
??????htmltext.Replace("$htmlformat["+i+"]",format[i]);???
????}???
????//----------????htm??浠?-----------------???????
????try???
????...{???
??????using(StreamWriter???sw=new???StreamWriter("瀛??捐矾寰???椤甸?㈠??",false,System.Text.Encoding.GetEncoding("GB2312")))???
????...{???
??????sw.WriteLine(htmltext);???
??????sw.Flush();???
??????sw.Close();???
????}???
????}???
????catch???
????...{???
????Response.Write???("The???file???could???not???be???wirte:");???
????}???
????灏?缁????
?????ㄦ?ゆ?规???浠ユ?逛究??????html??浠躲??绋?搴?浣跨?ㄤ???寰????挎?????姝ゅ?归???挎?㈠ぇ????绱???妯℃?块??搴???甯稿揩????