C#使用XMLHTTP获得网页源代码

using MSXML2;

        MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTP();
        string url = "http://www.163.com/";
        xmlhttp.open("GET", url, false, null, null);
        xmlhttp.send("");
        Byte[] b = (Byte[])xmlhttp.responseBody;
        string content = System.Text.ASCIIEncoding.UTF8.GetString(b, 0, b.Length);
        //string content = System.Text.Encoding.GetEncoding("GB2312").GetString(b).Trim();

posted on 2009-03-30 16:05  alon  阅读(257)  评论(0编辑  收藏  举报

导航