打印

[NET精华教程] .net教程:老外编的程序(八):在csharp里面使用http get方法

.net教程:老外编的程序(八):在csharp里面使用http get方法

/author: duncan mackenzie
using system;
using system.net;
using system.io;

namespace makeagetrequest_charp

{
    /// <summary>
    /// summary description for class1.
    /// </summary>
    class class1
    {
        static void main(string[] args)
        {
            string surl;
            surl = "http://www.microsoft.com";

            webrequest wrgeturl;
            wrgeturl = webrequest.create(surl);
            
            webproxy myproxy = new webproxy("myproxy",80);

            myproxy.bypassproxyonlocal = true;

            wrgeturl.proxy = webproxy.getdefaultproxy();

            stream objstream;
            objstream = wrgeturl.getresponse().getresponsestream();

            streamreader objreader = new streamreader(objstream);

            string sline = "";
            int i = 0;

            while (sline!=null)
            {
                i++;

                sline = objreader.readline();
                if (sline!=null)
                    console.writeline("{0}:{1}",i,sline);
            }
            console.readline();
        }
    }<



TOP

返回顶部
AYBlue

Processed in 0.045219 second(s), 7 queries.

当前时区 GMT+8, 现在时间是 2009-1-8 15:52 京ICP备06054220号

清除 Cookies - 联系我们 - 163K.com - Archiver - WAP