|
5金钱
public void CookieTest()
{
string jumpurl = "http://bbs.xmfish.com/read-htm-tid-11574877.html";
string loginurl="http://bbs.xmfish.com/login.php";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.sufeinet.com/member.php?mod=logging&action=login&loginsubmit=yes&loginhash=LlbhQ&inajax=1 HTTP/1.1",//URL 必需项
Encoding = null,//编码格式(utf-8,gb2312,gbk) 可选项 默认类会自动识别
//Encoding = Encoding.Default,
Method = "post",//URL 可选项 默认为Get
//Timeout = 100000,//连接超时时间 可选项默认为100000
//ReadWriteTimeout = 30000,//写入Post数据超时时间 可选项默认为30000
//IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
//Cookie = "",//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Referer = "http://www.sufeinet.com/member.php?mod=logging&action=login",//来源URL 可选项
Postdata = "formhash=ee18bfaa&referer=http://www.sufeinet.com/&loginfield=username&username=用户名&password=密码&questionid=0&answer=",
//Allowautoredirect = true
};
HttpResult result = http.GetHtml(item);
string cookie = string.Empty;
foreach (CookieItem s in HttpCookieHelper.GetCookieList(result.Cookie))
{
if (s.Key.Contains("24a79_"))
{
cookie += HttpCookieHelper.CookieFormat(s.Key, s.Value);
}
}
item = new HttpItem()
{
URL = "http://www.sufeinet.com/forum.php?mod=post&action=newthread&fid=76",
Cookie = result.Cookie,
};
result = http.GetHtml(item);//目前这个里面是未登入的状态,这里一直不成功
}
说明:这是我用我们论坛来测试也不行,我用了好几个网站,都无法成功,这个cookie怎么不自动转换,跪求各位大侠解答,非常感谢! |
|