还是登陆不进去啊。
[C#] 纯文本查看 复制代码 private void button1_Click(object sender, EventArgs e)
{
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://127.0.0.1/dede/login.php",//URL 必需项
Method = "post",//URL 可选项 默认为Get
Referer = "http://127.0.0.1/dede/login.php?gotopage=%2Fdede%2Findex.php",
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Postdata = "gotopage=%2Fdede%2Findex.php&dopost=login&adminstyle=newdedecms&userid=admin&pwd=admin&sm1=",//Post要发送的数据
//Allowautoredirect = true,
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请请求的Html
string html = result.Html;
//获取请求的Cookie
string cookie = result.Cookie;
cookie = HttpHelper.GetSmallCookie(cookie);
textBox1.Text = cookie;
item = new HttpItem()
{
URL = "http://127.0.0.1/dede/index.php",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
Cookie = cookie,
Referer = "http://127.0.0.1/dede/login.php",
Allowautoredirect=true,
// ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
};
result=http.GetHtml(item);
textBox2.Text = result.Html;
}
获取到的cookie是:
PHPSESSID=birbr3b62s177k1br4edj8k8m4;DedeUserID=1;DedeUserID__ckMd5=281bfc97ddb43a5c;DedeLoginTime=1429949847;DedeLoginTime__ckMd5=d4dd5f7d368faa60;
和正确的cookie很像,但就是无法登陆。
|