Click here to Skip to main content
15,894,539 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: volatile misbehaves Pin
Vaclav_19-May-18 14:36
Vaclav_19-May-18 14:36 
GeneralRe: volatile misbehaves Pin
leon de boer20-May-18 4:41
leon de boer20-May-18 4:41 
GeneralRe: volatile misbehaves Pin
Vaclav_20-May-18 5:44
Vaclav_20-May-18 5:44 
GeneralRe: volatile misbehaves Pin
leon de boer20-May-18 20:35
leon de boer20-May-18 20:35 
GeneralRe: volatile misbehaves Pin
Vaclav_21-May-18 3:18
Vaclav_21-May-18 3:18 
GeneralRe: volatile misbehaves Pin
leon de boer21-May-18 4:33
leon de boer21-May-18 4:33 
Question__sync_synchronize stops processor ? Pin
Vaclav_16-May-18 10:31
Vaclav_16-May-18 10:31 
AnswerRe: __sync_synchronize stops processor ? Pin
Randor 16-May-18 12:15
professional Randor 16-May-18 12:15 
GeneralRe: __sync_synchronize stops processor ? Pin
Vaclav_16-May-18 13:15
Vaclav_16-May-18 13:15 
GeneralRe: __sync_synchronize stops processor ? Pin
Randor 16-May-18 14:10
professional Randor 16-May-18 14:10 
GeneralRe: __sync_synchronize stops processor ? Pin
Vaclav_17-May-18 3:22
Vaclav_17-May-18 3:22 
QuestionTo install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
manoharbalu14-May-18 19:30
manoharbalu14-May-18 19:30 
AnswerRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Victor Nijegorodov14-May-18 20:24
Victor Nijegorodov14-May-18 20:24 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
manoharbalu14-May-18 20:50
manoharbalu14-May-18 20:50 
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 

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.