void CHTTPgetView::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();
// the URL we'll display at the end
CString sURL ( "http://CoverYourASP.com/default.asp#news" );
// create an internet session
CInternetSession csiSession;
CHttpConnection* pHTTPServer = NULL;
CFtpConnection* pFTPServer = NULL;
CHttpFile* pFile = NULL;
CString sGetFromURL ( "http://aspwire.com/getnews.asp?site=secret&lang=1&cnt=10" );
CString sSendToURL ( "ftp://CoverYourASP.com/" );
try
{
// parse URL to get server/object/port
CString sServerName;
CString sObject;
INTERNET_PORT nPort;
DWORD dwServiceType;
if ( !AfxParseURL ( sGetFromURL, dwServiceType, sServerName, sObject, nPort ) )
throw;
// open HTTP connection
pHTTPServer = csiSession.GetHttpConnection ( sServerName, nPort );
// get HTTP object
pFile = pHTTPServer->OpenRequest ( CHttpConnection::HTTP_VERB_GET, sObject, NULL, 1, NULL, NULL, INTERNET_FLAG_RELOAD );
pFile->SendRequest();
// open file to store raw data into
CStdioFile cfRaw ( "News.txt", CFile::modeCreate | CFile::modeReadWrite );
TCHAR sRaw [1024];
while ( pFile->ReadString ( sRaw, 1023 ) )
cfRaw.WriteString ( sRaw );
pFile->Close();
pHTTPServer->Close();
// open file to store formatted data into
TCHAR* sNewsFile = _T( "News.asp" );
CStdioFile cfASP ( sNewsFile, CFile::modeCreate | CFile::modeWrite );
cfASP.WriteString ( _T("<%\nfunction ShowNews ( )\n{\n") );
cfASP.WriteString ( _T("\tOut('');\n") );
cfASP.WriteString ( _T("\tOut(' (Read how this is done)
');\n") ); cfASP.WriteString ( _T("\tOut('
") ); break; case 3: // title sLine.Replace ( "'", "\\'" ); cfASP.WriteString ( sLine ); cfASP.WriteString ( _T(" | ") ); if ( bNewRow ) cfASP.WriteString ( _T ( "