将url网址的内容转换为html

using System.IO;
using System.Net;

private static string UrlToHtml(string url,System.Text.Encoding encode)
    {
     string strHtml = "<BASE HREF=\"" + url + "\"/>";
     try
     {
      StreamReader sr;

      WebRequest HttpWebRequest = WebRequest.Create(url);
      WebResponse HttpWebResponse = HttpWebRequest.GetResponse();

      sr = new StreamReader(HttpWebResponse.GetResponseStream(),encode);
      strHtml += sr.ReadToEnd();
      sr.Close();
     }
     catch
     {}
     finally
     {}

     return strHtml;
    }

posted @ 2007-10-11 22:42  jacktu  阅读(2704)  评论(1编辑  收藏  举报