一直result.html显示 本次请求并未返回任何数据 ,在 苏飞大大你的开发助手1.0带上 所有参数也是一样,我就考虑到是不是使用cookiecontain,还有就是http 1.1的问题。。。结果都不行。。。。
源码附上吧。。。用户名密码已经带上。。。
[C#] 纯文本查看 复制代码 string strCookie = string.Empty;
string strLoginState = string.Empty;
HttpItem item = new HttpItem();
HttpHelper http = new HttpHelper();
HttpResult result = new HttpResult();
string strPost = string.Empty;
//获得登陆页面的cookie ,使用CookieCollection 取出杂项
item = new HttpItem()
{
URL = "http://yueceyuekaixin.3g.ganji.com/bj_user/login/?ifid=yueceyuekaixin_client&backUrl=http%3A%2F%2F3g.ganji.com%2Fmisc%2Fyueceyuekaixin%2F%3F%26ifid%3Dclient_ycykx_banner%26qq-pf-to%3Dpcqq.c2c%26ssid%3D",
Referer = "http://yueceyuekaixin.3g.ganji.com/bj_user/login/?ifid=yueceyuekaixin_client&backUrl=http%3A%2F%2F3g.ganji.com%2Fmisc%2Fyueceyuekaixin%2F%3F%26ifid%3Dclient_ycykx_banner%26qq-pf-to%3Dpcqq.c2c%26ssid%3D",
UserAgent = "Mozilla/5.0 (Linux; U; Android 4.1.2; zh-cn; GT-I9268 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
ResultCookieType = ResultCookieType.CookieCollection,
};
http = new HttpHelper();
result = http.GetHtml(item);
CookieCollection cookieImageCollection = result.CookieCollection;
//POST登陆,item.Header.Add("x-requested-with", "XMLHttpRequest")加上防止http 1.1不兼容
strPost = "username=13621701498&password=hello5&backUrl=http%3A%2F%2F3g.ganji.com%2Fmisc%2Fyueceyuekaixin%2F%3F%26ifid%3Dclient_ycykx_banner%26qq-pf-to%3Dpcqq.c2c%26ssid%3D";
item = new HttpItem()
{
URL = "http://yueceyuekaixin.3g.ganji.com/bj_user/login/?ifid=new_shouye_cpdenglu",
Referer = "http://yueceyuekaixin.3g.ganji.com/bj_user/login/?ifid=yueceyuekaixin_client&backUrl=http%3A%2F%2F3g.ganji.com%2Fmisc%2Fyueceyuekaixin%2F%3F%26ifid%3Dclient_ycykx_banner%26qq-pf-to%3Dpcqq.c2c%26ssid%3D",
UserAgent = "Mozilla/5.0 (Linux; U; Android 4.1.2; zh-cn; GT-I9268 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
Postdata = strPost,
Method = "POST",
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
CookieCollection = cookieImageCollection,
ResultCookieType = ResultCookieType.CookieCollection,
};
item.Header.Add("x-requested-with", "XMLHttpRequest");
http = new HttpHelper();
result = http.GetHtml(item);
|