//发送GET请求到HTTP站点

        //       string userName = "******";
        //string tagUrl = "http://cang.baidu.com/" + userName + "/tags";
        //CookieCollection cookies = new CookieCollection();//如何从response.Headers["Set-Cookie"];中获取并设置CookieCollection的代码略
        //response = HttpWebResponseUtility.CreateGetHttpResponse(tagUrl, null, null, cookies);
        /// <summary>
        /// 发送POST请求到HTTP站点  以登录51CTO为例
        /// </summary>
        public static void Login51CTO()
        {
            string loginUrl = "http://home.51cto.com/index.php?s=/Index/doLogin";
            string userName = "******";
            string password = "******";

            IDictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("email", userName);
            parameters.Add("passwd", password);

            HttpWebResponse response = HttpWebResponseUtility.CreatePostHttpResponse(loginUrl, parameters, null, null, Encoding.UTF8, null);
        }
        //POST数据到HTTPS站点,用它来登录百度
        public static void LoginBaiDuTest()
        {
            string   loginUrl = "https://passport.baidu.com/?login";
            string   userName = "******";
            string   password = "******";
            string   tagUrl   = "http://cang.baidu.com/" + userName + "/tags";
            Encoding encoding = Encoding.GetEncoding("gb2312");
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("tpl", "fa");
            parameters.Add("tpl_reg", "fa");
            parameters.Add("u", tagUrl);
            parameters.Add("psp_tt", "0");
            parameters.Add("username", userName);
            parameters.Add("password", password);
            parameters.Add("mem_pass", "1");
            HttpWebResponse response     = HttpWebResponseUtility.CreatePostHttpResponse(loginUrl, parameters, null, null, encoding, null);
            string          cookieString = response.Headers["Set-Cookie"];
        }