[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;
textBox1.Text = html;
item = new HttpItem()
{
URL = "http://127.0.0.1/dede/index.php",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
Cookie=result.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=d58l6h4plr9h6lt3mfme4blvl3; path=/,DedeUserID=1; expires=Sat, 25-Apr-2015 14:44:48 GMT; path=/,DedeUserID__ckMd5=281bfc97ddb43a5c; expires=Sat, 25-Apr-2015 14:44:48 GMT; path=/,DedeLoginTime=1429886688; expires=Sat, 25-Apr-2015 14:44:48 GMT; path=/,DedeLoginTime__ckMd5=0acf464f1a4d0b67; expires=Sat, 25-Apr-2015 14:44:48 GMT; path=/
但正确的cookie是:menuitems=1_1%2C2_1%2C3_1; PHPSESSID=qsdlc4fn0g1thas52c7kcjq9i7; DedeUserID=1; DedeUserID__ckMd5=281bfc97ddb43a5c; DedeLoginTime=1429886343; DedeLoginTime__ckMd5=5f29aecfca6f6867
|