抓取网页内容

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Text;
namespace Rss
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                WebRequest request = WebRequest.Create("http://www.emedchina.net/");
                WebResponse response = request.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));

                Label1.Text = reader.ReadToEnd();

                reader.Close();
                reader.Dispose();
                response.Close();
            }
            catch (Exception ex)
            {
                Label1.Text = ex.Message;
            }

        }
    }
}

原文地址:https://www.cnblogs.com/hhq80/p/1521808.html