Click here to Skip to main content
15,896,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: To assign string from String table to a controll's caption at design time? Pin
codeII30-Jul-07 23:58
codeII30-Jul-07 23:58 
GeneralRe: To assign string from String table to a controll's caption at design time? Pin
Nelek31-Jul-07 0:46
protectorNelek31-Jul-07 0:46 
JokeRe: To assign string from String table to a controll's caption at design time? [modified] Pin
CPallini30-Jul-07 22:40
mveCPallini30-Jul-07 22:40 
QuestionTaskbarnotifier Pin
vicky0000030-Jul-07 21:41
vicky0000030-Jul-07 21:41 
AnswerRe: Taskbarnotifier Pin
Nelek30-Jul-07 21:45
protectorNelek30-Jul-07 21:45 
AnswerRe: Taskbarnotifier Pin
ashukasama30-Jul-07 21:49
ashukasama30-Jul-07 21:49 
AnswerRe: Taskbarnotifier Pin
Nishad S30-Jul-07 21:52
Nishad S30-Jul-07 21:52 
QuestionParasing website data : intermitten rubbish characters retrived Pin
awah30-Jul-07 21:28
awah30-Jul-07 21:28 
Parasing website data : intermitten rubbish characters retrived

hi, i am making a program to parse data from website, to do that i need to download the file

Step1: download file

CString Data;<br />
//CString Buffer;<br />
	DeleteUrlCacheEntry(url);// delete the old stupid cache<br />
<br />
HINTERNET IntOpen = ::InternetOpen("Sample", LOCAL_INTERNET_ACCESS, NULL, 0, 0);<br />
HINTERNET handle = ::InternetOpenUrl(IntOpen, url, NULL, NULL, NULL, NULL);<br />
HANDLE hFile	= ::CreateFile("c:\\index.txt", GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);<br />
 <br />
char Buffer[1024];<br />
DWORD dwRead =0;<br />
while(::InternetReadFile(handle, Buffer, sizeof(Buffer), &dwRead) == TRUE)<br />
{<br />
	if ( dwRead == 0) <br />
	 break;<br />
	DWORD dwWrite = 0;<br />
	::WriteFile(hFile, Buffer, dwRead, &dwWrite, NULL);<br />
	Data+=Buffer;<br />
}<br />
<br />
 ::CloseHandle(hFile);<br />
::InternetCloseHandle(handle);<br />


the Cstring "Data" contains the website in a plain text
step2 : parse the data using brackets
because a lot of data in within <> brackets, this can be used to reference the desired data

<br />
// this function look for the text and removes "bracket_distance" number of <>, then return the result <br />
// eg. "dsfsd<><><><>6.35<>", item = dsfsd, bracket_distance = 4<br />
CString Mydialog::Parse_Backets(CString file_string, CString item, int bracket_distance)<br />
{<br />
	file_string.ReleaseBuffer();<br />
<br />
	int start_index;<br />
	int end_index;<br />
	start_index = file_string.Find(item);<br />
	if(start_index == -1)<br />
	{<br />
		CString error_string = "Error";<br />
		error_flag = 1;<br />
		return error_string;<br />
	}<br />
	for(int i =0; i <bracket_distance; i++)<br />
	{<br />
		start_index = file_string.Find(">",start_index)+1;<br />
	}<br />
	end_index = file_string.Find("<",start_index) - 1;<br />
	file_string=file_string.Mid(start_index, end_index-start_index+1  );<br />
	return file_string;<br />
}



now the problem is once in a while i get rubbish characters. Like the actual value when i browse to the website, should be 0.55 , i get 0.aj5m5, or even 0.1595

the website is http://stquote.sgx.com/live/st/STStock.asp?stk=G

does anyone knows how to solve this problem?
using:
- mfc
- VC6.0
AnswerRe: Parasing website data : intermitten rubbish characters retrived Pin
Roger Broomfield31-Jul-07 2:22
Roger Broomfield31-Jul-07 2:22 
GeneralRe: Parasing website data : intermitten rubbish characters retrived Pin
awah31-Jul-07 2:28
awah31-Jul-07 2:28 
GeneralRe: Parasing website data : intermitten rubbish characters retrived Pin
David Crow31-Jul-07 2:51
David Crow31-Jul-07 2:51 
GeneralRe: Parasing website data : intermitten rubbish characters retrived Pin
Roger Broomfield31-Jul-07 4:45
Roger Broomfield31-Jul-07 4:45 
QuestionCBrush DeleteObject Problem Pin
Febil Chacko Thanikal30-Jul-07 21:12
Febil Chacko Thanikal30-Jul-07 21:12 
JokeRe: CBrush DeleteObject Problem Pin
Naveen30-Jul-07 21:17
Naveen30-Jul-07 21:17 
Questionmore over i have tally software Pin
munna_vannan30-Jul-07 21:03
munna_vannan30-Jul-07 21:03 
AnswerRe: more over i have tally software Pin
Cedric Moonen30-Jul-07 21:18
Cedric Moonen30-Jul-07 21:18 
AnswerRe: more over i have tally software Pin
mandanani30-Jul-07 21:36
mandanani30-Jul-07 21:36 
Questionhi i m working in asp.net Pin
munna_vannan30-Jul-07 20:58
munna_vannan30-Jul-07 20:58 
AnswerRe: hi i m working in asp.net Pin
Don Box30-Jul-07 21:06
Don Box30-Jul-07 21:06 
AnswerRe: hi i m working in asp.net Pin
Mark Salsbery31-Jul-07 8:07
Mark Salsbery31-Jul-07 8:07 
QuestionRe: hi i m working in asp.net Pin
Hamid_RT31-Jul-07 21:18
Hamid_RT31-Jul-07 21:18 
Questionhow to import data to tally from xml? Pin
munna_vannan30-Jul-07 20:53
munna_vannan30-Jul-07 20:53 
QuestionMember Function Template Pin
Andy Rama30-Jul-07 20:42
Andy Rama30-Jul-07 20:42 
AnswerRe: Member Function Template [modified] Pin
Nelek30-Jul-07 20:54
protectorNelek30-Jul-07 20:54 
GeneralRe: Member Function Template Pin
Andy Rama30-Jul-07 21:00
Andy Rama30-Jul-07 21:00 

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.