一下段代码在登录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;
}
}
username={0}&userpwd={1}&x=18&y=16