Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Victor Nijegorodov14-May-18 22:56
Victor Nijegorodov14-May-18 22:56 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
manoharbalu15-May-18 3:10
manoharbalu15-May-18 3:10 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Victor Nijegorodov15-May-18 3:40
Victor Nijegorodov15-May-18 3:40 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
manoharbalu15-May-18 3:48
manoharbalu15-May-18 3:48 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
leon de boer15-May-18 5:50
leon de boer15-May-18 5:50 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Victor Nijegorodov15-May-18 9:57
Victor Nijegorodov15-May-18 9:57 
AnswerRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Joe Woodbury17-May-18 5:55
professionalJoe Woodbury17-May-18 5:55 
QuestionCInternetSession OpenURL Pin
_Flaviu14-May-18 0:34
_Flaviu14-May-18 0:34 
Hi. I am trying to get the source code of a web page in order to analyze it. And here is the code for code retrieving:

C++
BOOL CCIFDoc::GetRemoteFile(CString sServer, CString sRemotePath, CString sParameter, CStringArray& saData)
{
	BOOL bRet = FALSE;
	CInternetSession ISession;
	CInternetFile* pIFile = NULL;
	CHttpFile* pHttpFile = NULL;
	LPCTSTR lpszAccept[] = {_T("*/*"), NULL};

	try
	{
		pIFile = (CInternetFile*)ISession.OpenURL(_T("http://") + sServer + sRemotePath + sParameter, 1, INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD);
		if(NULL != pIFile)
		{
			CString sTemp;
			while(pIFile->ReadString(sTemp))
				saData.Add(sTemp + _T("\n"));
		}

		bRet = (saData.GetSize() > 0);
	}
	catch(CInternetException* pException)
	{
		pException->GetErrorMessage(m_sError.GetBuffer(_MAX_PATH), _MAX_PATH);
		m_sError.ReleaseBuffer();
		pException->Delete();
	}
	catch(CMemoryException* pMemException)
	{
		pMemException->GetErrorMessage(m_sError.GetBuffer(_MAX_PATH), _MAX_PATH);
		m_sError.ReleaseBuffer();
		pMemException->Delete();
	}

	if(NULL != pIFile)
	{
		pIFile->Close();
		delete pIFile;
	}

	if(NULL != pHttpConnect)
	{
		pHttpConnect->Close();
		delete pHttpConnect;
	}

	ISession.Close();

	return bRet;
}

Classic code.

But there is some web pages which is retrieving without html body, or with other body than I have seen in my browser. Let's take an example: type www.bnr.ro in your browser, and see the page. But when I retrieve this address with code from above, here is the result:

HTML
<!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=UTF-8"/>

    <title>Eroare/ Error</title>

    <style type="text/css">

    	* { margin: 0; padding: 0; border: 0; outline: none; font-size: 100%; }

    	body { font-family: Arial, sans-serif; }

    	#wrapper { text-align: center; margin: 3em auto;}

    	p { padding: 0.5em 0; }

    	a { color: #0039a6; text-decoration: none; }

    	a:hover, a:focus { color: #e9994a; }

    </style>

</head>

<body>

	<div id="wrapper">

		<a href="http://www.bnr.ro"><img src="http://www.bnr.ro/images/logo.png"></a>

    	<p>Eroare neprevazută / Unexpected error.</p>

    	<p><a href="http://www.bnr.ro">Înapoi pe prima pagină / Back to the homepage</a>.</p>

    </div>

</body>

</html>



How can I retrieve the source code just I seen in my browser ?

Thank you.


modified 14-May-18 7:34am.

AnswerRe: CInternetSession OpenURL Pin
Jochen Arndt14-May-18 2:01
professionalJochen Arndt14-May-18 2:01 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 2:24
_Flaviu14-May-18 2:24 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt14-May-18 2:29
professionalJochen Arndt14-May-18 2:29 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 2:34
_Flaviu14-May-18 2:34 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 23:00
_Flaviu14-May-18 23:00 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 23:07
_Flaviu14-May-18 23:07 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 0:01
professionalJochen Arndt15-May-18 0:01 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu15-May-18 0:21
_Flaviu15-May-18 0:21 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 0:31
professionalJochen Arndt15-May-18 0:31 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu15-May-18 0:44
_Flaviu15-May-18 0:44 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 1:21
professionalJochen Arndt15-May-18 1:21 
AnswerRe: CInternetSession OpenURL Pin
Randor 15-May-18 9:46
professional Randor 15-May-18 9:46 
QuestionWhy can't variables be declared in a switch statement Pin
tracyhe12313-May-18 20:34
tracyhe12313-May-18 20:34 
AnswerRe: Why can't variables be declared in a switch statement Pin
Richard MacCutchan13-May-18 20:58
mveRichard MacCutchan13-May-18 20:58 
Questionwhy passing argument by reference(&ref) in a template function shows error ? but works fine if arguments passed by pointer(*ptr) ? Pin
Tarun Jha13-May-18 1:46
Tarun Jha13-May-18 1:46 
AnswerRe: why passing argument by reference(&ref) in a template function shows error ? but works fine if arguments passed by pointer(*ptr) ? Pin
CPallini13-May-18 2:56
mveCPallini13-May-18 2:56 
GeneralRe: why passing argument by reference(&ref) in a template function shows error ? but works fine if arguments passed by pointer(*ptr) ? Pin
Tarun Jha26-May-18 9:50
Tarun Jha26-May-18 9:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.