ホームページ  >  記事  >  php教程  >  读取网页页面代码 并保存

读取网页页面代码 并保存

WBOY
WBOYオリジナル
2016-06-06 20:01:331170ブラウズ

//使用空间 using System.Net; using System.IO; if (!IsPostBack) { WebClient client = new WebClient(); string reply = client.DownloadString("http://www.sina.com"); TextArea1.Value = reply; } FileStream fs = new FileStream(@"c:/aa.html", File

 

 

 

//使用空间

using System.Net;

using System.IO; 

 

if (!IsPostBack)

        {

            WebClient client = new WebClient();

            string reply = client.DownloadString("http://www.sina.com");

            TextArea1.Value = reply;

        }

 

 

        FileStream fs = new FileStream(@"c:/aa.html", FileMode.Create, FileAccess.Write);

        StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);

        sw.Write(TextArea1.Value);

        sw.Close();

        fs.Close();

 

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。