Save the dynamic ASPX page to static HTM files

zhaozj2021-02-16  57

Call this method, you can save the dynamic ASP.NET page to a static HTM file.

String url = http://www.9cbs.net/fly.aspx? id = 515225;

GetPagehtml (URL);

Private string getPagehtml (String Url) {string result; WebRequest myResponse; WebRequest myrequest = system.net.httpwebrequest.create (URL); MyResponse = myRequest.getResponse ();

using (StreamReader MyReader = new StreamReader (MyResponse.GetResponseStream (), System.Text.Encoding.Default)) {Result = MyReader.ReadToEnd (); MyReader.Close ();} FileStream fs = new FileStream ( "c: // Flystudio.htm ", Filemode.create, FileAccess.write; streamwriter sw = new streamwriter (fs, system.text.encoding.default); sw.close (); fs.close (); Return Result;}

Explain, please see the MSDN that comes with VS.NET ...

:) flystudio@2911.net

转载请注明原文地址:https://www.9cbs.com/read-22882.html

New Post(0)