| So now I have a working application to view the results on our web site - but I haven't done any real work. Using MFC's classes even the next part is easy. I'll briefly describe the code as I go but - (here's the copout) - use MSDN to get help on parts you don't understand! Start by opening an HTTP connection to the news source. CInternetSession is the key to this process - just create one, and call the GetHttpConnection method: // create an internet session
CInternetSession csiSession;
// parse URL to get server/object/port
CString sGetFromURL ( "http://aspwire.com/getnews.asp?site=secret&lang=1&cnt=10" );
if ( !AfxParseURL ( sGetFromURL, dwServiceType, sServerName, sObject, nPort ) )
throw;
// open HTTP connection
CHttpConnection* pHTTPServer = NULL;
pHTTPServer = csiSession.GetHttpConnection ( sServerName, nPort );
// get HTTP object
CHttpFile* pFile = NULL;
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];
// transfer the data into our local file
while ( pFile->ReadString ( sRaw, 1023 ) )
cfRaw.WriteString ( sRaw );
// I've finished with the HTTP objects
// so close them
pFile->Close();
pHTTPServer->Close();
|
That's the first part done! I now have a file on our local disc that contains the news feed's raw data. It's in the format URL, Date, Type, Title - here's a section of the file I just created: http://aspwire.com/redir?2888 7/28 article Hosting multiple domains on one IP Address http://aspwire.com/redir?2865 7/28 article 404 Error Page Now I have to get the data I need from this file, and format it the way I need. Part 3: Creating our ASP file...  |