怎么用vc取得一个网页的返回值?

csdnzhu 2004-10-18 08:36:53
我要向一个网页发送一个请求
例如以下
http://202.102.29.155/qxtweb/sendmessage.jsp?sp_code=2004444&username=test&password=test&tomobile=05126186109&msg=hello
把上面的字串直接输入IE地址栏内,如果地址栏内显示一个1就表示成功了,怎么用VC得到这个结果呢?

...全文
180 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
gjd111686 2004-10-18
  • 打赏
  • 举报
回复
int COAMinderDlg::GetTaskAmount()
{
iAmount=0;
iMsgAmount=0;
iFileAmount=0;
CInternetSession m_Session("DigitalTitan");
CHttpConnection* pServer=NULL;
CHttpFile* pFile=NULL;
CHttpFile* pTaskFile=NULL;
CString strServerName=strServerIP;
INTERNET_PORT nPort=(INTERNET_PORT)atoi(strServerPort);
CString strURL=strLoginAddress;
try
{
pServer=m_Session.GetHttpConnection(strServerName,nPort);
pFile=pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strURL,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
CString strHeaders=_T("Content-Type: application/x-www-form-urlencoded");
CString strFormData;
strFormData.Format("UserName=%s&Password=%s&action=submit",strLoginUserName,strLoginPassword);
//AfxMessageBox(strFormData,MB_ICONINFORMATION);
if(pFile->SendRequest(strHeaders,(LPVOID)(LPCTSTR)strFormData,strFormData.GetLength())==0)
{
//AfxMessageBox("网络异常...",MB_ICONINFORMATION);
pFile->Close();
delete pFile;
pServer->Close();
delete pServer;
m_Session.Close();
}
else
{
pFile->ReadString(strInfo);
if(strInfo.Find("Apache Tomcat/4.1.18 - Error report",0)!=-1)
{
AfxMessageBox("服务器产生错误.",MB_ICONINFORMATION);
return 0;
}
pFile->Close();
delete pFile;
pServer->Close();
delete pServer;

pTaskFile=(CHttpFile*)m_Session.OpenURL(strLoginDataAddress);
CString strBuf;
CString strText;
while(pTaskFile->ReadString(strText))
{
strBuf+="\r\n";
strBuf+=strText;
}
pTaskFile->Close();
delete pTaskFile;
m_Session.Close();
//AfxMessageBox(strBuf,MB_ICONINFORMATION);
int iBegin,iEnd;
iBegin=0;iEnd=0;
CString strTemp;
strTemp="";
//信息提取
//关键字一
iBegin=strBuf.Find("更多方案",0);
if(iBegin!=-1)
{
//关键字二
iEnd=strBuf.Find("已办理方案</font>",iBegin);
strTemp=strBuf.Mid(iBegin+9,iEnd-(iBegin+9));
strTemp.MakeLower();
//分隔符
int iResult=strTemp.Find("<tr",0);
if(iResult==-1)
{
//
}
else if(iResult<strTemp.GetLength())
{
while(iResult!=-1)
{
iAmount++;
iResult=strTemp.Find("<tr",iResult+3);
}
//修正结果
iAmount=iAmount-5;
}
}
//另关键字:新申请(3)新归档方案(0)
iBegin=strBuf.Find("新申请(",0);
iEnd=strBuf.Find(")",iBegin);
strTemp=strBuf.Mid(iBegin+9,iEnd-(iBegin+9));
iMsgAmount=atoi(strTemp);

iBegin=strBuf.Find("新归档方案(",0);
iEnd=strBuf.Find(")",iBegin);
strTemp=strBuf.Mid(iBegin+13,iEnd-(iBegin+13));
iFileAmount=atoi(strTemp);
}
}
catch(CInternetException* e)
{
char strErrorBuf[255];
e->GetErrorMessage(strErrorBuf,255,NULL);
AfxMessageBox(strErrorBuf,MB_ICONINFORMATION);
pFile=NULL;
delete pFile;
pTaskFile=NULL;
delete pTaskFile;
pServer=NULL;
delete pServer;
m_Session.Close();
return 0;
}
return iAmount;
}

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧