- 积分
- 40165
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
发表于 2013-7-25 13:14:13
|
显示全部楼层
[code=csharp] HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.aizhan.com/login.php",//URL这里都是测试URl 必需项
Method = "post",//URL 可选项 默认为Get
ContentType = "application/x-www-form-urlencoded",
Postdata = "refer=&email=328666469@qq.com&password=jiahonglin",
};
//得到HTML代码
HttpResult result = http.GetHtml(item);
//生成Cookie
string scookie = HttpCookieHelper.CookieFormat("PHPSESSID", HttpCookieHelper.GetCookieValue("PHPSESSID", result.Cookie));
scookie += HttpCookieHelper.CookieFormat("userId", HttpCookieHelper.GetCookieValue("userId", result.Cookie));
scookie += HttpCookieHelper.CookieFormat("userName", HttpCookieHelper.GetCookieValue("userName", result.Cookie));
scookie += HttpCookieHelper.CookieFormat("userGroup", HttpCookieHelper.GetCookieValue("userGroup", result.Cookie));
scookie += HttpCookieHelper.CookieFormat("userSecure", HttpCookieHelper.GetCookieValue("userSecure", result.Cookie));
item = new HttpItem()
{
URL = "http://www.aizhan.com/user.php",//URL这里都是测试URl 必需项
Cookie = scookie
};
//得到HTML代码
result = http.GetHtml(item);
richTextBox1.Text = result.Html;[/code]
HttpCookieHelper在Httphelper的下载处有下载,可以使用这个类进行Cookie格式化就行了。 |
|