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

using System;
using MSXML2;//引用COM:Microsoft XML, v3.0

namespace ConsoleApplication1
{

    class Program
    {
        static void Main(string[] args)
        {
            XMLHTTP xmlhttp = new XMLHTTP();
            string url = "http://www.mzwu.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();
            Console.WriteLine(content);

            Console.ReadKey();
        }
    }

}


上一篇: ASP获取图片的高度和宽度
下一篇: 查找资料的常用方法
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
最新日志:
评论: 0 | 引用: 0 | 查看次数: 5833
发表评论
登录后再发表评论!