为什么我抓不下这个网页?
以下代码已经可以直接运行.就是抓不下该网站的网页,还抓不下www.163.net 的主页.
???
CString sServer="www.jk888.com";
CString sDocPath="/";
CInternetSession oSession("InterSession");
CHttpConnection *pCon=NULL;
CHttpFile *pFile=NULL;
pCon=oSession.GetHttpConnection(sServer,(INTERNET_PORT)80);
if(!pCon)
{
oSession.Close();
}
pFile=pCon->OpenRequest(CHttpConnection::HTTP_VERB_GET,sDocPath,
NULL,1,NULL,NULL,INTERNET_FLAG_RELOAD);
if(!pFile)
{
oSession.Close();
}
try{
pFile->AddRequestHeaders("");
pFile->SendRequest();
}catch(...)
{
oSession.Close();
}
DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet);
if(dwRet!=HTTP_STATUS_OK)
{
oSession.Close();
}
if(pFile->GetLength()==0)
{
oSession.Close();
}
void *pBuffer=malloc(1024);
//pFile->ReadHuge(pBuffer,iCount);
CString sContent,sTemp;
int iResult;
do
{
iResult=pFile->Read(pBuffer,1023);
if(iResult==0)break;
sTemp=(char*)pBuffer;
sTemp=sTemp.Left(iResult);
sContent+=sTemp;
}while(iResult>0);
oSession.Close();
printf("%s",sContent);