|
本帖最后由 leenkon 于 2013-8-14 09:24 编辑
昨天升级了最新的HttpHelper,增加了KeepAlive属性,可以取得cookie了,根据网银抓包,只发送了cookie,但是post过去返回错误代码,应该是系统检测了什么地方木有通过。望高手帮忙!附上我写的测试代码:- void Button1Click(object sender, EventArgs e)
- {
- HttpHelper HttpHelper = new HttpHelper();
- HttpItem HttpItem=new HttpItem(){
- CerPath= "D:\\11.cer",//证书绝对路径 可选项不需要证书时可以不写这个参数
- URL="https://mybank.icbc.com.cn/icbc/perbank/index.jsp",
- Accept="text/html, application/xhtml+xml, */*",
- ContentType="application/x-www-form-urlencoded",
- Referer="https://mybank.icbc.com.cn",
- Method="GET",
- KeepAlive=true,
- };
- HttpResult Result = HttpHelper.GetHtml(HttpItem);
- string Cookies=Result.Cookie.Replace("; Path=/","");
- string sessionID=Cookies.Substring(15,23);
- COOK=Result.CookieCollection;
- MessageBox.Show(Cookies+"\n"+sessionID);
-
- HttpItem=new HttpItem(){
- CerPath= "D:\\11.cer",
- URL="https://mybank.icbc.com.cn/servlet/AsynGetDataServlet",
- Accept="application/json, text/javascript, */*; q=0.01",
- ContentType="application/x-www-form-urlencoded; charset=UTF-8",
- Referer="https://mybank.icbc.com.cn/servlet/ICBCINBSReqServlet",
- UserAgent="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0) LBBROWSER",
- Method="POST",
- Postdata="step=3&area_code=4402&SessionId="+sessionID+"&tranCode=A00033",
- //Postdata="dse_sessionId="+sessionID+"&dse_applicationId=-1&dse_operationName=per_GoldQueryPriceOp&dse_pageId=30&step=1&goldType=rmb_903&kType=realtime&pageType=small&curtype=903&acflag=1&area_code=2312&submitFlag=0",
- Allowautoredirect=true,
- KeepAlive=true,
- CookieCollection=COOK,
- //Cookie=Result.Cookie,
- };
- //HttpItem.CookieCollection=COOK;
- HttpItem.Header.Add("x-requested-with","XMLHttpRequest");
- HttpItem.Header.Add("Cache-Control","no-cache");
- HttpItem.Header.Add("DNT","1");
- Result = HttpHelper.GetHtml(HttpItem);
- string str=Result.Html;
- MessageBox.Show(str+Result.Cookie);
- }
复制代码 请求标头:
请求标头
Post数据:
post数据
发送的Cookie:
发送的cookie
返回的结果:
得到的结果
工程下载地址:
MMTool.rar
(51.48 KB, 下载次数: 228)
|
|