Cstrings ChuomaoDlg: : httpGetRequest (cstrings url)
{
CInternetSession m_InetSession;
Cstrings strHtml;
BOOL b=InternetSetOption (m_InetSession INTERNET_OPTION_RESET_URLCACHE_SESSION, NULL, 0);
Try {
CHttpFile * pFile=(CHttpFile *) m_InetSession OpenURL (url);
If (pFile!=NULL)
{
DWORD statusCode;
PFile - & gt; QueryInfoStatusCode (statusCode);
If (statusCode==HTTP_STATUS_OK)
{
MessageBox (_T (" ok "));
TCHAR buf [1024]={0};
Char TMP [2048]={0};
While (pFile - & gt; ReadString (buf, 1024))
{
For (int I=0, j=0; i{
TMP [j]=LOBYTE (buf [I]);//low byte of word
TMP [j + 1)=HIBYTE (buf [I]);//word high byte
}
Cstrings ss (TMP);
StrHtml +=ss;
}
}
}
M_InetSession. Close ();
PFile - & gt; Close ();
The delete pFile;
}
The catch (CInternetException * e) {
TCHAR info [1024]={0};
E - & gt; GetErrorMessage (info, 1024);
}
The catch (CMemoryException * e)
{
TCHAR info [1024]={0};
E - & gt; GetErrorMessage (info, 1024);
}
The catch (CFileException * e)
{
TCHAR info [1024]={0};
E - & gt; GetErrorMessage (info, 1024);
}
The catch (CException * e)
{
TCHAR info [1024]={0};
E - & gt; GetErrorMessage (info, 1024);
}
Return strHtml;
}
CodePudding user response:
Baidu and qq is HTTPSCodePudding user response:
http://blog.csdn.net/daiyutage/article/details/9567779 MFC parse web pages source codeCodePudding user response:
Note that this is not the code of the problem, is to obtain the value is empty, I open their own projects in the public server no problem, but open the baidu, qq this would be a gain value is empty, but the connection is successful, is the first set the header was they thought is to block the machine?CodePudding user response: