|
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem() {
URL = "http://www.sufeinet.com",
Method = "get",
ContentType = "text/html",
};
HttpResult result = http.GetHtml(item);
if (result.StatusCode != HttpStatusCode.OK)
{
MessageBox.Show("Get http://www.sufeinet.com failed!");
return;
}
string cookie = result.Cookie;
HttpItem itemLogin = new HttpItem(){
URL = "http://www.sufeinet.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1",
Method = "post",
ContentType = "application/x-www-form-urlencoded",
Referer = "http://www.sufeinet.com/",
Postdata = "fastloginfield=username&username=aaa&password=bbb&quickforward=yes&handlekey=ls", ///这里aaa和bbb只是用于说明,实际上用的是正确的用户名和密码
Cookie = cookie,
};
HttpResult resultLogin = http.GetHtml(itemLogin);
if (resultLogin.StatusCode != HttpStatusCode.OK )
{
MessageBox.Show("Post " + itemLogin.URL + " failed!");
return;
}
cookie = resultLogin.Cookie;
string html = result.Html;
if (html.IndexOf("window.location.href='http://www.sufeinet.com/'") <= 0 )
{
MessageBox.Show("Login Failed!");
return;
}
请问,为何总是无法登录成功?哪里出错了呢?
|
|