Click here to Skip to main content
13,799,313 members

C / C++ / MFC

 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Victor Nijegorodov14-May-18 23:56
memberVictor Nijegorodov14-May-18 23:56 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
manoharbalu15-May-18 4:10
membermanoharbalu15-May-18 4:10 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Victor Nijegorodov15-May-18 4:40
memberVictor Nijegorodov15-May-18 4:40 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
manoharbalu15-May-18 4:48
membermanoharbalu15-May-18 4:48 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
leon de boer15-May-18 6:50
memberleon de boer15-May-18 6:50 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Victor Nijegorodov15-May-18 10:57
memberVictor Nijegorodov15-May-18 10:57 
AnswerRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Joe Woodbury17-May-18 6:55
professionalJoe Woodbury17-May-18 6:55 
QuestionCInternetSession OpenURL Pin
_Flaviu14-May-18 1:34
member_Flaviu14-May-18 1: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:

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:

<!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 3:01
mvpJochen Arndt14-May-18 3:01 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 3:24
member_Flaviu14-May-18 3:24 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt14-May-18 3:29
mvpJochen Arndt14-May-18 3:29 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 3:34
member_Flaviu14-May-18 3:34 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu15-May-18 0:00
member_Flaviu15-May-18 0:00 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu15-May-18 0:07
member_Flaviu15-May-18 0:07 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 1:01
mvpJochen Arndt15-May-18 1:01 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu15-May-18 1:21
member_Flaviu15-May-18 1:21 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 1:31
mvpJochen Arndt15-May-18 1:31 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu15-May-18 1:44
member_Flaviu15-May-18 1:44 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 2:21
mvpJochen Arndt15-May-18 2:21 
AnswerRe: CInternetSession OpenURL Pin
Randor 15-May-18 10:46
professional Randor 15-May-18 10:46 
QuestionWhy can't variables be declared in a switch statement Pin
tracyhe12313-May-18 21:34
membertracyhe12313-May-18 21:34 
AnswerRe: Why can't variables be declared in a switch statement Pin
Richard MacCutchan13-May-18 21:58
protectorRichard MacCutchan13-May-18 21: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 2:46
memberTarun Jha13-May-18 2: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 3:56
mvpCPallini13-May-18 3: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 10:50
memberTarun Jha26-May-18 10: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.


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.181207.3 | Last Updated 14 Dec 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid