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

C / C++ / MFC

 
GeneralRe: Extracting data from the webpages using MFC Pin
kilt13-Oct-09 2:12
kilt13-Oct-09 2:12 
GeneralRe: Extracting data from the webpages using MFC Pin
CPallini13-Oct-09 2:23
mveCPallini13-Oct-09 2:23 
GeneralRe: Extracting data from the webpages using MFC Pin
Richard MacCutchan13-Oct-09 3:12
mveRichard MacCutchan13-Oct-09 3:12 
GeneralRe: Extracting data from the webpages using MFC Pin
Iain Clarke, Warrior Programmer13-Oct-09 4:43
Iain Clarke, Warrior Programmer13-Oct-09 4:43 
GeneralRe: Extracting data from the webpages using MFC Pin
Rajesh R Subramanian13-Oct-09 4:46
professionalRajesh R Subramanian13-Oct-09 4:46 
AnswerRe: Extracting data from the webpages using MFC Pin
David Crow13-Oct-09 3:46
David Crow13-Oct-09 3:46 
GeneralRe: Extracting data from the webpages using MFC Pin
NaveenHS15-Oct-09 1:21
NaveenHS15-Oct-09 1:21 
AnswerRe: Extracting data from the webpages using MFC Pin
msn9213-Oct-09 14:50
msn9213-Oct-09 14:50 
I have struggled with loading web page sources and parsing them too.

This is the way I prefer and it's the easiest one I know:

#include "afxinet.h"
...
BOOL GetPageSource(CString& url, CString& source){
	CInternetSession ises;
	CFile* file=new CFile();
	try{//There might occur a connection error
	  file=ises.OpenURL(url);//CInternetSession::OpenURL(url) returns a source code in CHttpFile;
	}
	catch(CInternetException* e){ //If an error occured, show messagebox with errorcode
		CString error=L"";
		error.Format(L"Connection error!\nError code: %ld",e->m_dwError);
		AfxMessageBox(error);
		return FALSE;
	}
	UINT len=1024;
	char buf[1024];
	source=L"";
	while(len>0){
		len=file->Read(buf,1024);
		if(len>0)source.Append(CString(buf),len);
	}
	file->Close();
	ises.Close();
	return TRUE;
}

You can use GetPageSource() function to get a page source.
For the parsing part, I use regex.
QuestionLink error [modified] Pin
ratprita12-Oct-09 23:46
ratprita12-Oct-09 23:46 
QuestionRe: Link error Pin
CPallini13-Oct-09 0:11
mveCPallini13-Oct-09 0:11 
AnswerRe: Link error Pin
Cedric Moonen13-Oct-09 0:20
Cedric Moonen13-Oct-09 0:20 
Questionfast fast fast Pin
__erfan__12-Oct-09 22:43
__erfan__12-Oct-09 22:43 
AnswerRe: fast fast fast Pin
CPallini12-Oct-09 22:57
mveCPallini12-Oct-09 22:57 
GeneralRe: fast fast fast Pin
__erfan__12-Oct-09 23:09
__erfan__12-Oct-09 23:09 
GeneralRe: fast fast fast Pin
CPallini13-Oct-09 0:01
mveCPallini13-Oct-09 0:01 
AnswerRe: fast fast fast Pin
Rajesh R Subramanian12-Oct-09 23:05
professionalRajesh R Subramanian12-Oct-09 23:05 
GeneralRe: fast fast fast Pin
__erfan__12-Oct-09 23:12
__erfan__12-Oct-09 23:12 
AnswerRe: fast fast fast Pin
Rolf Kristensen13-Oct-09 0:07
Rolf Kristensen13-Oct-09 0:07 
JokeRe: fast fast fast Pin
CPallini13-Oct-09 0:14
mveCPallini13-Oct-09 0:14 
GeneralRe: fast fast fast Pin
__erfan__13-Oct-09 0:27
__erfan__13-Oct-09 0:27 
QuestionStored Procedure Pin
MsmVc12-Oct-09 22:14
MsmVc12-Oct-09 22:14 
AnswerRe: Stored Procedure Pin
Rajesh R Subramanian12-Oct-09 22:16
professionalRajesh R Subramanian12-Oct-09 22:16 
GeneralRe: Stored Procedure Pin
MsmVc12-Oct-09 22:19
MsmVc12-Oct-09 22:19 
Questionhow to caputre screen including movie play ? Pin
rambojanggoon12-Oct-09 21:19
rambojanggoon12-Oct-09 21:19 
AnswerRe: how to caputre screen including movie play ? Pin
Rajesh R Subramanian12-Oct-09 21:25
professionalRajesh R Subramanian12-Oct-09 21:25 

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.