高分求教用VC自动登录网页,获取网页返回的COOKIE 求示例代码,wininet的,我CHTTPFILE的 QUERYINFO 一直出去,不用QUERYINFO 可以正常获取页面内容,求高手给一个可运行代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CString strObject; INTERNET_PORT nPort; CString strServer; CString strHeaders =_T("Content-Type: application/x-www-form-urlencoded"); CString strFormData;// = _T("phone=13878750055"); DWORD dwServiceType; CString strContent=""; CHttpConnection* pServer = NULL; CHttpFile* pFile = NULL; CString strURL=g_strWebAddr_HG+"app/member/login.php"; CString strRetMsg; strFormData.Format("uid=%s&langx=en-us&mac=&ver=&JE=true&username=%s&passwd=%s&number=%04d", g_strUID_HG,g_strUsername_HG,g_strPassword_HG,rand()%10000); try { if(!AfxParseURL(strURL,dwServiceType,strServer,strObject,nPort)|| dwServiceType != INTERNET_SERVICE_HTTP) { //MessageBox(_T("不是HTTP站点"),_T("错误")); return FALSE; } pServer = g_Session_HG.GetHttpConnection(strServer,nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strObject);//NULL,1,NULL,NULL, pFile->AddRequestHeaders(_T("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*")); pFile->AddRequestHeaders(_T("Referer: ")+strURL); pFile->AddRequestHeaders(_T("Accept-Language: zh-cn")); pFile->AddRequestHeaders(_T("Content-Type: application/x-www-form-urlencoded")); // pFile->AddRequestHeaders(_T("Accept-Encoding: gzip, deflate")); pFile->AddRequestHeaders(_T("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)")); //pFile->SendRequest(); BOOL result = pFile->SendRequest(NULL,0, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength()); DWORD dwRet; pFile->QueryInfoStatusCode(dwRet); if (dwRet != HTTP_STATUS_OK) { return FALSE; } CString cookie; pFile->QueryInfo(HTTP_QUERY_SET_COOKIE,cookie); if( cookie!="" ) g_Session_HG.SetCookie(strURL,"",cookie); 如果是带验证码的网页登录比较麻烦,如果不带验证码的比较好办一些,你查看网页源代码,找到form表单中各个表单项后,将各表单项组合成字符串如:username=abc&password=123456,最后再用Post方式将这个字符串作为参数提交到服务器上即可。但是注意有的网站在提交时需要将post参数URLEncode,在服务器反馈后可以自己分析信息头,也可以用pFile->QueryInfo(HTTP_QUERY_SET_COOKIE,cookie);得到各个cookie值。 比如说:126邮箱怎么进去呢?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>126网易免费邮--你的专业电子邮局</title><meta content="中文专业免费邮箱,邮箱伴侣,随身邮,邮箱贺卡,自写短信,免费网易网盘,网络硬盘,网络记事本,rss阅读,Free Email" name="keywords"><meta content="网易126邮箱--专业电子邮局提供免费网络硬盘网络硬盘.126网易免费邮是网易公司顷力打造的专业电子邮局,3G免费空间,支持超大20兆附件。126邮箱使用创新Ajax技术, 同等网络环境下,页面响应时间减少90%以上,垃圾邮件及病毒有效拦截率超过98%和99.8%。" name="description"><meta name="robots" content="index, follow" /><meta name="googlebot" content="index, follow" /><link rel="shortcut icon" href="http://www.126.com/favicon.ico" /><link href="http://mimg.126.com/index/style_index_080718.css" rel="stylesheet" type="text/css" /><style type="text/css">.Speed_add{position:absolute; left:-50px;top:261px;width:205px;height:20px;line-height:20px;text-align:right;z-index:999}</style> </div> <form method="post" action="http://entry.126.com/cgi/login" name="form" onSubmit="return fCheck()"> <input name="domain" type="hidden" value="126.com" /> <input name="language" type="hidden" value="0" /> <input name="bCookie" type="hidden" value="" /> <input name="username" type="hidden" value="" /> <div class="ge" style="height:9px"></div> <p class="MR_pinp"><span>用户名</span> <input type="text" name="user" onMouseOver="fEvent('mouseover',this)" onFocus="fEvent('focus',this)" onBlur="fEvent('blur',this)" onMouseOut="fEvent('mouseout',this)" maxlength="20" tabindex="1"/> <b class="m126" title="@126.com"></b></p> <div class="ge"></div> <p class="MR_pinp LH"><span>密 码</span> <input onMouseOver="fEvent('mouseover',this)" onFocus="fEvent('focus',this)" onBlur="fEvent('blur',this)" onMouseOut="fEvent('mouseout',this)" name="password" type="password" size="16" tabindex="2" maxlength="20"/> <a href="http://reg.163.com/RecoverPasswd1.shtml" target="_blank" style="margin-top:7px">忘记密码了?</a></p> <div class="ge"></div> <p class="MR_pinp LH"><span>版 本</span> <select name="style" id="login_select"> <option value="-1" selected="selected"> 默 认 </option> <option value="23"> 逍遥 3.0 </option> <option value="21"> 极速 3.0 </option> <option value="3"> 简约 3.0 </option> </select> <!-- <a href="http://uinfo.mail.126.com/xy3/index.htm" target="_blank" class="sj_a">升级逍遥3.0</a> --> </p> <div class="ge"></div> <p class="MR_check" style="margin-top:14px"><span class="wy"> </span> <input type="checkbox" value="" name="remUser" checked="checked" id="rem_U"style="vertical-align:middle;" /> <label for="rem_U">在此电脑上记住用户名</label> </p> <p class="MR_check LH2"><span class="wy"> </span> <input type="checkbox" value="" name="secure" id="secure" checked="checked" style="vertical-align:middle;" /> <label for="secure">SSL安全登录</label> <a href="http://help.163.com/08/1111/16/4QG0DVBL00752CTH.html" target="_blank"><img style="display:inline; margin-top:-2px; vertical-align:middle" src="http://mimg.126.com/index/whyssl_126.gif" alt="什么是SSL登录" title="什么是SSL登录" /> </a> </p> <div class="ge"></div> <p class="MR_But" style="margin-top:8px"><span class="wy"> </span> <input type="submit" value="登 录" class="inp_L1" onMouseOver="this.className='inp_L2'" onMouseOut="this.className='inp_L1'" id="input_btn1" name="enter.x" tabindex="4" onClick="setCookie('ntes_mail_firstpage','normal');saveLoginType();" /> <input type="submit" value="登录网盘" class="inp_L1" onMouseOver="this.className='inp_L2'" onMouseOut="this.className='inp_L1'" id="input_btn2" tabindex="4" onClick="setCookie('ntes_mail_firstpage','normal');saveLoginType();" style="display:none"/> </p> <script>fInitUser();fSetLogType();fVoidIE5();</script> </form> </div> </div></div><!--最新消息--><div id="UN"> <div id="News"> <div id="News_TL"></div> <div id="News_Tt"><a href="http://kefu.mail.126.com/" target="_blank">最新动态</a></div> <div id="News_Tr"></div> <!--消息内容--> <div id="News_Cc"> <ul> <li style="width:200px"><a href="http://pro.163.com/event.ng/Type=click&FlightID=139240&AdID=141080&TargetID=953&Values=31,43,51,60,72,84,100,110,150,312,316,330,332,457,568,588,702,733,734,774,788,942,943,944,948,949,950,951,1006,1123,1130,1131,1135&Redirect=http://cnt.zhaopin.com/Market/whole_counter.jsp%3Fsid%3D121111284%26site%3D126youxiangshouyeTL%26url%3Dhttp://images.zhaopin.com/zhaopin/denglu/index.html" target="_blank" >快点!新年新Job,好工作属于你</a></li> <li style="width:230px"><a href="http://tools.mail.163.com/sdy/" target="_blank" style="">下载网易首个邮箱客户端:“闪电邮” </a> </li> <li style="width:200px"><a href="http://love.mail.163.com/valentine/main.do" target="_blank">免费送你和爱人去新加坡过情人节 </a></li> </ul> <!-- <a href="http://kefu.mail.126.com/" target="_blank" class="fcopy">>></a> --> </div> <div id="News_Cr"></div> </div> <!--底部区域--> <div id="Footer"><a href="http://corp.163.com/index_gb.html" target="_blank">关于网易</a> <a href="http://mail.blog.163.com/" target="_blank">邮箱官方博客</a> <a href="http://www.188.com/index.htm?from=126mail" target="_blank">财富邮</a> <a href="http://appsms.mail.126.com/mailmms/smsnotify/reg_out.jsp?id=indexbottom" target="_blank">随身邮</a> <a href="http://www.126.com/help/mscan_01.htm" target="_blank">邮箱伴侣</a> <a href="http://cards.163.com/" target="_blank">精美贺卡</a> <a href="http://safesurf.china.cn/data_form.php" target="_blank">举报违法信息</a> <a href="http://help.163.com" target="_blank">客户服务</a><br /> <a href="http://corp.163.com/gb/legal/legal.html" target="_blank">相关法律</a> | 网易公司版权所有 <span class="fcopy">© </span>1997-2009</div></div><!--网络统计start--> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="ReqCol" width="0" height="0" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" style="height:0;width:0"> <param name="movie" value="ReqCol.swf" /> <param name="FlashVars" value="requestURL=http://www.yeah.net/favicon.ico&submitURL=http://220.181.28.120/result.html"/> <param name="quality" value="high" /> <param name="bgcolor" value="#869ca7" /> <param name="allowScriptAccess" value="always" /> <embed src="ReqCol.swf" FlashVars="requestURL=http://www.yeah.net/favicon.ico&submitURL=http://220.181.28.120/result.html" quality="high" bgcolor="#869ca7" width="0" height="0" name="ReqCol" align="middle" play="true" loop="false" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"> </embed> </object><!--网络统计end--></body><script language="JavaScript"><!--function setCookie(name, value, isForever) { document.cookie = name + "=" + escape(value) + ";domain=126.com" + (isForever?";expires="+ (new Date(2099,12,31)).toGMTString():"");}var sRef = location.search;var ArrFrom = sRef.split("from=");if(ArrFrom[1] == null || ArrFrom[1] == "undefined"){ ArrFrom[1] = "";}var gFrom = ArrFrom[1];document.getElementById("lnkReg").href += gFrom;window.onresize();//--></script><iframe src="http://mimg.163.com/mailvisited/index.htm#126" style="display:none;"></iframe><!--DLEOANNA--><a href="http://uinfo.mail.163.com/cgi-bin/hseed/two.pl"></a></html> pFile->AddRequest里都要加什么啊 126邮箱,带账号密码的...用上面的方法改了改,不行.谁位帮我看看,void CPost2Dlg::OnOK() { // TODO: Add extra validation here CString strObject; INTERNET_PORT nPort; CString strFormData; DWORD dwServiceType; CInternetSession g_Session_HG("My Session"); CString strContent=""; CHttpConnection* pServer = NULL; CHttpFile* pFile = NULL; CString strURL="http://www.126.com"; CString strRetMsg; strFormData="user=yindoor000&password=6675027&style=-1&remUser=checked&secure=checked"; if(!AfxParseURL(strURL,dwServiceType,strServer,strObject,nPort)|| dwServiceType != INTERNET_SERVICE_HTTP) { return ; } pServer = g_Session_HG.GetHttpConnection(strURL,nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strObject);//NULL,1,NULL,NULL, pFile->AddRequestHeaders("Content-Type:text/html; charset=gb2312"); BOOL result = pFile->SendRequest(NULL,0, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength()); DWORD dwRet; pFile->QueryInfoStatusCode(dwRet); if (dwRet != HTTP_STATUS_OK) { return ; } CString cookie; pFile->QueryInfo(HTTP_QUERY_SET_COOKIE,cookie); if( cookie!="" ) g_Session_HG.SetCookie(strURL,"",cookie); CDialog::OnOK(); CString str="" CString a=""; while(pFile->ReadString(a)) { str+=a; str+="\r\n"; } SetDlgItemText(IDC_EDIT1,str);} pServer = g_Session_HG.GetHttpConnection(strServer,nPort); pFile->SendRequest之间没有取返回值吗?如何获得 请指教@! ......这么没人气啊..楼主再加二百分吧.谁能解释下strObject的意思? 好,现在知道strObject是form里的action了.但是我把126上的"http://entry.126.com/cgi/login" 加上,结果却是"找不到指定的文件" 如何解决呢? 给你一段代码 m_strSendData.Format("/imageservice/GetBillImage?USERNAME=%s&PASSWORD=%s&BILLNO=%s&BILLTYPE=%d&ISSUB=%d\r\n",m_strUserName,m_strPassword,m_strBillNO,m_nBillType,m_cbSub.GetCurSel());// m_strSendData.Format("/imageservice/GetBillImage"); CInternetSession session("ImageSession"); CHttpConnection* pServer = NULL; CHttpFile* pFile = NULL; char szBuff[1024]; try { static TCHAR hdrs[] = _T("Accept: */*\r\nUser-Agent: Java1.3.1_01\r\nContent-Type: application/x-www-form-urlencoded\r\n"); static TCHAR accept[] = _T("Accept: */*\r\n"); CString strServerName; CString strHtml=""; INTERNET_PORT nPort; DWORD dwRet;// strServerName = "http://" + m_strServerIP; nPort = m_nPort; pServer = session.GetHttpConnection(strServerName,0,nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,m_strSendData,NULL,1,NULL,"HTTP/1.1"); pFile->AddRequestHeaders(hdrs); pFile->SendRequestEx(m_strSendData.GetLength()); pFile->WriteString(m_strSendData); pFile->EndRequest(); pFile->QueryInfoStatusCode(dwRet); if (dwRet == HTTP_STATUS_OK) { CString strLine; while ((pFile->ReadString(strLine))>0) { strHtml += strLine; } } delete pFile; delete pServer; CFile cfImage; cfImage.Open("c:\\imageinfo.txt",CFile::modeCreate|CFile::modeReadWrite); cfImage.Write(strHtml,strHtml.GetLength()); cfImage.Close(); } catch (CInternetException* pEx) { //catch errors from WinInet } session.Close(); 主要是HTTP报头和 读出的问题 第一次取得COOKIE,第二次就不能取到COOKIE 什么原因? 只说了一个小问题,事实上,要了解的书包括:http协议(尤其是http头的内容),然后根据协议处理得到的数据javascript cookie产生的机制现在趋于复杂化,往往在javascript中产生关键的cookie 下面的代码我一直在用 至于COOKIE ,有个更简单的办法可以直接去COOKIE的目录进行读取您需要的话,可以给您写SAMPLE CODEVARIANT id, index; CComPtr<IDispatch> spDispatch; CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2; CComPtr<IHTMLElement> pElement; CComPtr<IHTMLElementCollection> pElementCol; CComPtr<IHTMLFormElement> pFormElement; CComPtr<IHTMLInputTextElement> pInputElement; if (m_pBrowserApp){ if (SUCCEEDED(m_pBrowserApp->get_Document((IDispatch**) &pDoc2))) if(pDoc2!=NULL) { { if (SUCCEEDED(pDoc2->get_forms(&pElementCol))) { // AfxMessageBox("IHTMLElementCollection"); long p=0; if(SUCCEEDED(pElementCol->get_length(&p))) if(p!=0) { // AfxMessageBox("1"); for(long i=0;i<=(p-1);i++) { V_VT(&id) = VT_I4; V_I4(&id) = i; V_VT(&index) = VT_I4; V_I4(&index) = 0; if(SUCCEEDED(pElementCol->item(id,index, &spDispatch))) { // AfxMessageBox("2"); pFormElement = NULL; if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLFormElement,(void**)&pFormElement))) { // AfxMessageBox("IHTMLFormElement"); long q=0; if(SUCCEEDED(pFormElement->get_length(&q))) for(long j=0;j<=(q-1);j++) { V_VT(&id) = VT_I4; V_I4(&id) = j; V_VT(&index) = VT_I4; V_I4(&index) = 0; spDispatch = NULL; if(SUCCEEDED(pFormElement->item(id,index, &spDispatch))) { pInputElement = NULL; if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLInputTextElement,(void**)&pInputElement))) { //AfxMessageBox("IHTMLInputTextElement"); CComBSTR value(in_strValue); CComBSTR type; CComBSTR name; pInputElement->get_type(&type); CString strtype(type); strtype.MakeUpper(); if ((strtype == L"TEXT") || (strtype == L"PASSWORD") ) { pInputElement->get_name(&name); CString strName(name); if(strName.Find(in_strEdtName)!=-1) { pInputElement->put_value(value); return true; } } } } } } } } } } } } } return false;} CreateFont//改变字体粗数,第四个参数咋无效果??? opencv 遇到 一个问题。在线求解答 关于CSting的一个问题 将钩子DLL注入某进程后,如何让钩子在进程中安装(installhook)? CMSFlexGrid类的问题 求教!关于《深入浅出mfc》中的一个问题? 智能电视是倒退 gina锁屏十分钟之后成功登录,但立马进去重启状态 在内存DC中创建的内存位图(卫星图象),BitBlt到窗口后却变成四幅,而绘制的地图却正常... 在对话框中如何得到当前的视图类? access数据库插入效率以及和内存使用 VC中ADO可执行的SQL的长度有限制么?
INTERNET_PORT nPort;
CString strServer;
CString strHeaders =_T("Content-Type: application/x-www-form-urlencoded");
CString strFormData;// = _T("phone=13878750055");
DWORD dwServiceType; CString strContent="";
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL; CString strURL=g_strWebAddr_HG+"app/member/login.php";
CString strRetMsg;
strFormData.Format("uid=%s&langx=en-us&mac=&ver=&JE=true&username=%s&passwd=%s&number=%04d",
g_strUID_HG,g_strUsername_HG,g_strPassword_HG,rand()%10000);
try
{
if(!AfxParseURL(strURL,dwServiceType,strServer,strObject,nPort)||
dwServiceType != INTERNET_SERVICE_HTTP)
{
//MessageBox(_T("不是HTTP站点"),_T("错误"));
return FALSE;
}
pServer = g_Session_HG.GetHttpConnection(strServer,nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strObject);//NULL,1,NULL,NULL,
pFile->AddRequestHeaders(_T("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"));
pFile->AddRequestHeaders(_T("Referer: ")+strURL);
pFile->AddRequestHeaders(_T("Accept-Language: zh-cn"));
pFile->AddRequestHeaders(_T("Content-Type: application/x-www-form-urlencoded"));
// pFile->AddRequestHeaders(_T("Accept-Encoding: gzip, deflate"));
pFile->AddRequestHeaders(_T("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)")); //pFile->SendRequest();
BOOL result = pFile->SendRequest(NULL,0,
(LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet); if (dwRet != HTTP_STATUS_OK)
{
return FALSE;
}
CString cookie;
pFile->QueryInfo(HTTP_QUERY_SET_COOKIE,cookie);
if( cookie!="" )
g_Session_HG.SetCookie(strURL,"",cookie);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>126网易免费邮--你的专业电子邮局</title>
<meta content="中文专业免费邮箱,邮箱伴侣,随身邮,邮箱贺卡,自写短信,免费网易网盘,网络硬盘,网络记事本,rss阅读,Free Email" name="keywords">
<meta content="网易126邮箱--专业电子邮局提供免费网络硬盘网络硬盘.126网易免费邮是网易公司顷力打造的专业电子邮局,3G免费空间,支持超大20兆附件。126邮箱使用创新Ajax技术, 同等网络环境下,页面响应时间减少90%以上,垃圾邮件及病毒有效拦截率超过98%和99.8%。" name="description">
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow" />
<link rel="shortcut icon" href="http://www.126.com/favicon.ico" />
<link href="http://mimg.126.com/index/style_index_080718.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.Speed_add{position:absolute; left:-50px;top:261px;width:205px;height:20px;line-height:20px;text-align:right;z-index:999}
</style> </div>
<form method="post" action="http://entry.126.com/cgi/login" name="form" onSubmit="return fCheck()">
<input name="domain" type="hidden" value="126.com" />
<input name="language" type="hidden" value="0" />
<input name="bCookie" type="hidden" value="" />
<input name="username" type="hidden" value="" />
<div class="ge" style="height:9px"></div>
<p class="MR_pinp"><span>用户名</span>
<input type="text" name="user" onMouseOver="fEvent('mouseover',this)" onFocus="fEvent('focus',this)" onBlur="fEvent('blur',this)" onMouseOut="fEvent('mouseout',this)" maxlength="20" tabindex="1"/> <b class="m126" title="@126.com"></b></p>
<div class="ge"></div>
<p class="MR_pinp LH"><span>密 码</span>
<input onMouseOver="fEvent('mouseover',this)" onFocus="fEvent('focus',this)" onBlur="fEvent('blur',this)" onMouseOut="fEvent('mouseout',this)" name="password" type="password" size="16" tabindex="2" maxlength="20"/>
<a href="http://reg.163.com/RecoverPasswd1.shtml" target="_blank" style="margin-top:7px">忘记密码了?</a></p>
<div class="ge"></div>
<p class="MR_pinp LH"><span>版 本</span> <select name="style" id="login_select">
<option value="-1" selected="selected"> 默 认 </option>
<option value="23"> 逍遥 3.0 </option>
<option value="21"> 极速 3.0 </option>
<option value="3"> 简约 3.0 </option>
</select>
<!-- <a href="http://uinfo.mail.126.com/xy3/index.htm" target="_blank" class="sj_a">升级逍遥3.0</a> -->
</p>
<div class="ge"></div>
<p class="MR_check" style="margin-top:14px"><span class="wy"> </span>
<input type="checkbox" value="" name="remUser" checked="checked" id="rem_U"style="vertical-align:middle;" />
<label for="rem_U">在此电脑上记住用户名</label> </p>
<p class="MR_check LH2"><span class="wy"> </span>
<input type="checkbox" value="" name="secure" id="secure" checked="checked" style="vertical-align:middle;" />
<label for="secure">SSL安全登录</label>
<a href="http://help.163.com/08/1111/16/4QG0DVBL00752CTH.html" target="_blank"><img style="display:inline; margin-top:-2px; vertical-align:middle" src="http://mimg.126.com/index/whyssl_126.gif" alt="什么是SSL登录" title="什么是SSL登录" />
</a>
</p>
<div class="ge"></div>
<p class="MR_But" style="margin-top:8px"><span class="wy"> </span> <input type="submit" value="登 录" class="inp_L1" onMouseOver="this.className='inp_L2'" onMouseOut="this.className='inp_L1'" id="input_btn1" name="enter.x" tabindex="4" onClick="setCookie('ntes_mail_firstpage','normal');saveLoginType();" />
<input type="submit" value="登录网盘" class="inp_L1" onMouseOver="this.className='inp_L2'" onMouseOut="this.className='inp_L1'" id="input_btn2" tabindex="4" onClick="setCookie('ntes_mail_firstpage','normal');saveLoginType();" style="display:none"/>
</p>
<script>fInitUser();fSetLogType();fVoidIE5();</script>
</form>
</div>
</div>
</div>
<!--最新消息--><div id="UN">
<div id="News">
<div id="News_TL"></div>
<div id="News_Tt"><a href="http://kefu.mail.126.com/" target="_blank">最新动态</a></div>
<div id="News_Tr"></div>
<!--消息内容-->
<div id="News_Cc">
<ul>
<li style="width:200px"><a href="http://pro.163.com/event.ng/Type=click&FlightID=139240&AdID=141080&TargetID=953&Values=31,43,51,60,72,84,100,110,150,312,316,330,332,457,568,588,702,733,734,774,788,942,943,944,948,949,950,951,1006,1123,1130,1131,1135&Redirect=http://cnt.zhaopin.com/Market/whole_counter.jsp%3Fsid%3D121111284%26site%3D126youxiangshouyeTL%26url%3Dhttp://images.zhaopin.com/zhaopin/denglu/index.html" target="_blank" >快点!新年新Job,好工作属于你</a>
</li>
<li style="width:230px"><a href="http://tools.mail.163.com/sdy/" target="_blank" style="">下载网易首个邮箱客户端:“闪电邮” </a> </li>
<li style="width:200px"><a href="http://love.mail.163.com/valentine/main.do" target="_blank">免费送你和爱人去新加坡过情人节
</a></li>
</ul>
<!-- <a href="http://kefu.mail.126.com/" target="_blank" class="fcopy">>></a> -->
</div> <div id="News_Cr"></div>
</div>
<!--底部区域-->
<div id="Footer"><a href="http://corp.163.com/index_gb.html" target="_blank">关于网易</a> <a href="http://mail.blog.163.com/" target="_blank">邮箱官方博客</a> <a href="http://www.188.com/index.htm?from=126mail" target="_blank">财富邮</a> <a href="http://appsms.mail.126.com/mailmms/smsnotify/reg_out.jsp?id=indexbottom" target="_blank">随身邮</a> <a href="http://www.126.com/help/mscan_01.htm" target="_blank">邮箱伴侣</a> <a href="http://cards.163.com/" target="_blank">精美贺卡</a> <a href="http://safesurf.china.cn/data_form.php" target="_blank">举报违法信息</a> <a href="http://help.163.com" target="_blank">客户服务</a><br />
<a href="http://corp.163.com/gb/legal/legal.html" target="_blank">相关法律</a> | 网易公司版权所有 <span class="fcopy">© </span>1997-2009</div></div>
<!--网络统计start-->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="ReqCol" width="0" height="0" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" style="height:0;width:0">
<param name="movie" value="ReqCol.swf" />
<param name="FlashVars" value="requestURL=http://www.yeah.net/favicon.ico&submitURL=http://220.181.28.120/result.html"/>
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="always" />
<embed src="ReqCol.swf" FlashVars="requestURL=http://www.yeah.net/favicon.ico&submitURL=http://220.181.28.120/result.html" quality="high" bgcolor="#869ca7" width="0" height="0" name="ReqCol" align="middle" play="true" loop="false" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
<!--网络统计end-->
</body>
<script language="JavaScript">
<!--
function setCookie(name, value, isForever) {
document.cookie = name + "=" + escape(value) + ";domain=126.com" + (isForever?";expires="+ (new Date(2099,12,31)).toGMTString():"");
}var sRef = location.search;
var ArrFrom = sRef.split("from=");
if(ArrFrom[1] == null || ArrFrom[1] == "undefined"){
ArrFrom[1] = "";
}
var gFrom = ArrFrom[1];
document.getElementById("lnkReg").href += gFrom;
window.onresize();
//-->
</script>
<iframe src="http://mimg.163.com/mailvisited/index.htm#126" style="display:none;"></iframe><!--DLEOANNA-->
<a href="http://uinfo.mail.163.com/cgi-bin/hseed/two.pl"></a></html>
谁位帮我看看,void CPost2Dlg::OnOK()
{
// TODO: Add extra validation here
CString strObject;
INTERNET_PORT nPort;
CString strFormData;
DWORD dwServiceType;
CInternetSession g_Session_HG("My Session");
CString strContent="";
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
CString strURL="http://www.126.com";
CString strRetMsg;
strFormData="user=yindoor000&password=6675027&style=-1&remUser=checked&secure=checked";
if(!AfxParseURL(strURL,dwServiceType,strServer,strObject,nPort)||
dwServiceType != INTERNET_SERVICE_HTTP)
{
return ;
}
pServer = g_Session_HG.GetHttpConnection(strURL,nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strObject);//NULL,1,NULL,NULL,
pFile->AddRequestHeaders("Content-Type:text/html; charset=gb2312");
BOOL result = pFile->SendRequest(NULL,0,
(LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet);
if (dwRet != HTTP_STATUS_OK)
{
return ;
}
CString cookie;
pFile->QueryInfo(HTTP_QUERY_SET_COOKIE,cookie);
if( cookie!="" )
g_Session_HG.SetCookie(strURL,"",cookie);
CDialog::OnOK();
CString str=""
CString a="";
while(pFile->ReadString(a))
{
str+=a;
str+="\r\n";
}
SetDlgItemText(IDC_EDIT1,str);
}
m_strSendData.Format("/imageservice/GetBillImage?USERNAME=%s&PASSWORD=%s&BILLNO=%s&BILLTYPE=%d&ISSUB=%d\r\n",m_strUserName,m_strPassword,m_strBillNO,m_nBillType,m_cbSub.GetCurSel());
// m_strSendData.Format("/imageservice/GetBillImage");
CInternetSession session("ImageSession");
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
char szBuff[1024];
try
{
static TCHAR hdrs[] = _T("Accept: */*\r\nUser-Agent: Java1.3.1_01\r\nContent-Type: application/x-www-form-urlencoded\r\n");
static TCHAR accept[] = _T("Accept: */*\r\n"); CString strServerName;
CString strHtml="";
INTERNET_PORT nPort;
DWORD dwRet;
// strServerName = "http://" + m_strServerIP;
nPort = m_nPort;
pServer = session.GetHttpConnection(strServerName,0,nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,m_strSendData,NULL,1,NULL,"HTTP/1.1");
pFile->AddRequestHeaders(hdrs);
pFile->SendRequestEx(m_strSendData.GetLength());
pFile->WriteString(m_strSendData);
pFile->EndRequest(); pFile->QueryInfoStatusCode(dwRet);
if (dwRet == HTTP_STATUS_OK)
{
CString strLine;
while ((pFile->ReadString(strLine))>0)
{
strHtml += strLine;
} }
delete pFile;
delete pServer;
CFile cfImage;
cfImage.Open("c:\\imageinfo.txt",CFile::modeCreate|CFile::modeReadWrite);
cfImage.Write(strHtml,strHtml.GetLength());
cfImage.Close();
}
catch (CInternetException* pEx)
{
//catch errors from WinInet
}
session.Close();
至于COOKIE ,有个更简单的办法可以直接去COOKIE的目录进行读取您需要的话,可以给您写SAMPLE CODEVARIANT id, index;
CComPtr<IDispatch> spDispatch;
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2;
CComPtr<IHTMLElement> pElement;
CComPtr<IHTMLElementCollection> pElementCol;
CComPtr<IHTMLFormElement> pFormElement;
CComPtr<IHTMLInputTextElement> pInputElement;
if (m_pBrowserApp){ if (SUCCEEDED(m_pBrowserApp->get_Document((IDispatch**) &pDoc2)))
if(pDoc2!=NULL)
{
{
if (SUCCEEDED(pDoc2->get_forms(&pElementCol)))
{
// AfxMessageBox("IHTMLElementCollection");
long p=0;
if(SUCCEEDED(pElementCol->get_length(&p)))
if(p!=0)
{
// AfxMessageBox("1");
for(long i=0;i<=(p-1);i++)
{ V_VT(&id) = VT_I4;
V_I4(&id) = i;
V_VT(&index) = VT_I4;
V_I4(&index) = 0; if(SUCCEEDED(pElementCol->item(id,index, &spDispatch)))
{ // AfxMessageBox("2");
pFormElement = NULL;
if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLFormElement,(void**)&pFormElement)))
{
// AfxMessageBox("IHTMLFormElement");
long q=0;
if(SUCCEEDED(pFormElement->get_length(&q)))
for(long j=0;j<=(q-1);j++)
{
V_VT(&id) = VT_I4;
V_I4(&id) = j;
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
spDispatch = NULL;
if(SUCCEEDED(pFormElement->item(id,index, &spDispatch)))
{
pInputElement = NULL;
if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLInputTextElement,(void**)&pInputElement)))
{
//AfxMessageBox("IHTMLInputTextElement");
CComBSTR value(in_strValue);
CComBSTR type;
CComBSTR name; pInputElement->get_type(&type); CString strtype(type);
strtype.MakeUpper(); if ((strtype == L"TEXT") || (strtype == L"PASSWORD") )
{
pInputElement->get_name(&name);
CString strName(name);
if(strName.Find(in_strEdtName)!=-1)
{
pInputElement->put_value(value);
return true;
}
}
}
}
}
}
}
}
}
} } }
} return false;
}