首页 新闻 会员 周边

请教登陆网页的winform程序--帮帮忙了,谢了

0
悬赏园豆:10 [已关闭问题] 关闭于 2009-02-10 15:56

一下段代码在登录chinahr.com是没问题,但是在登录51job.com时却不行。是什么原因?希望大伙能帮忙解决一下,哥们儿俺谢你了!

string.Format("username={0}&password={1}", this.Username, this.Password));其中的username和password是否是数据库中的字段?是不是因为51job的数据库中字段不是这样拼写的?因为我修改了password为userpassword后,登录chinahr.com也不成功。

我改怎么改才能登录51job.com.希望知道的朋友告诉我实现原理,在这先谢大家了。

      //根据url做登陆请求
                WebResponse responce = this.doPost(url,
                    string.Format("username={0}&password={1}", this.Username, this.Password));

    /// <summary>
        /// 发送Post类型请求
        /// </summary>
        /// <param name="url">请求地址</param>
        /// <param name="postData">参数</param>
        /// <returns></returns>
        public WebResponse doPost(string url, string postData)
        {
            try
            {
                byte[] paramByte = Encoding.Default.GetBytes(postData); // 转化
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
                webRequest.Method = "POST";
                webRequest.ContentType = "application/x-www-form-urlencoded";
                webRequest.ContentLength = paramByte.Length;
                webRequest.CookieContainer = this.cookies;
                //webRequest.Timeout = 5000;
                Stream newStream = webRequest.GetRequestStream();
                newStream.Write(paramByte, 0, paramByte.Length);    //写入参数
                newStream.Close();
                return webRequest.GetResponse();
            }
            catch (Exception ce)
            {
                throw ce;
            }
        }

hhshuai的主页 hhshuai | 初学一级 | 园豆:135
提问于:2009-02-09 23:47
< >
分享
所有回答(1)
0

username={0}&userpwd={1}&x=18&y=16

laaaaaa | 园豆:241 (菜鸟二级) | 2009-02-10 10:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册