|
ÅØ½ºÆ®ÆÄÀÏ·Î ÀÐÀ¸½Å´Ù°í Çϼŵµ ÇÊ¿äÇÑ ºÎºÐÀº ÆÄ½ÌÇÏ¿© »ç¿ëÇÏ¼Å¾ß ÇÕ´Ï´Ù..
¾Æ·¡¼Ò¼Ò´Â HTMLÀ» txt¹®¼·Î ÀúÀåÇÏ´Â ¼Ò½ºÀÔ´Ï´Ù.
¾î´À »çÀÌÆ®¿¡¼ ¹Þ¾Æ³õÀº°Çµ¥ ±â¾ïÀÌ ¾È³ª³×¿ä..
//stdafx.h ÆÄÀÏ¿¡ #include <afxinet.h> ¸¦ Ãß°¡Çϼ¼¿ä..
BOOL GetSourceHtml(CString theUrl)
{
// this first block does the actual work
CInternetSession session;
CInternetFile* file = NULL;
try
{
// try to connect to the URL
file = (CInternetFile*) session.OpenURL(theUrl);
}
catch (CInternetException* m_pException)
{
// set file to NULL if there"s an error
file = NULL;
m_pException->Delete();
}
// most of the following deals with storing the html to a file
CStdioFile dataStore;
if (file)
{
CString somecode;
BOOL bIsOk = dataStore.Open(_T("C:\\rawHtml.txt"),
CFile::modeCreate
|
CFile::modeWrite
|
CFile::shareDenyWrite
|
CFile::typeText);
if (!bIsOk)
return FALSE;
// continue fetching code until there is no more
while (file->ReadString(somecode) != NULL)
{
dataStore.WriteString(somecode);
}
file->Close();
delete file;
}
else
{
dataStore.WriteString(_T("Could not establish a connection
with the server..."));
}
}
|