下载网页数据_zj

using System.Net;
using System.Text;

// GET方式:
try
{
    WebClient myclient = new WebClient();
    byte[] databuffer = myclient.DownloadData(URL);
    string maintext = Encoding.Default.GetString(databuffer);
    myclient.Dispose();
}
catch (System.Net.WebException err)
{
    MessageBox.Show(err.Message);
}

// POST方式:
try
{
    WebClient myclient = new WebClient();
    string url = "http://www.cninfo.com.cn/jjzx/zcjz.jsp";
    NameValueCollection nvc = new NameValueCollection();
    nvc.Add("fundCode", code值);    
    nvc.Add("smt", "查询");
    byte[] databuffer = myclient.UploadValues(url, "POST", nvc);
    string maintext = Encoding.Default.GetString(databuffer);
    myclient.Dispose();
}
catch (System.Net.WebException err)
{
    MessageBox.Show(err.Message);
}
Contributors: FHL