|
我的代码中get一个url可以返回cookie,如果使用这个返回的cookie再get一个url,返回的result.cookie是空的,我试过用第一次返回的cookie post数据出去也是返回空的cookie,请问应该怎么解决?
[code=csharp] HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
item = new HttpItem()
{
URL = realHost,//URL 必需项
Method = "get",//URL 可选项 默认为Get
Cookie = "",//字符串Cookie 可选项
Referer = this.realHost,//来源URL 可选项
UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT6.0)",//用户的浏览器类型,版本,操作系统 可选项有默认值
ContentType = "text/html",//返回类型 可选项有默认值
};
result = http.GetHtml(item);
string cookie = result.Cookie; //这时候能获得cookies
//获取验证码图片
verifiUrl = realHost + "CodeVali.aspx";
item = new HttpItem()
{
URL = this.verifiUrl,//URL 必需项
Method = "get",//URL 可选项 默认为Get
// Referer = this.realHost,//来源URL 可选项
Cookie = cookie,//字符串Cookie 可选项
UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT6.0)",//用户的浏览器类型,版本,操作系统 可选项有默认值
ContentType = "text/html",//返回类型 可选项有默认值
ResultType = ResultType.Byte,
};
result = http.GetHtml(item);
cookie = result.Cookie; //这时候cookies空[/code]
|
|