//stdafx.h 파일에 #include를 추가 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) { somecode += "\r\n"; dataStore.WriteString(somecode); } file->Close(); delete file; } else { dataStore.WriteString(_T("Could not establish a connection with the server...")); } return 0; }
필요에 의해서 찾아본 소스로 그냥 데브피아에서 퍼온 자료이다...
매개변수로 소스를 저장하고 싶은 웹페이지의 주소를 넘겨주면 된다...
저장되는 파일 위치 지정 등만 살짝 수정해서 쓰면 될듯함...
출처 : 데브피아 -> 질문&답변