//************************************** //INCLUDE files for :^!!~ A better HTML Source Grabber/Stealer ~!!^ //************************************** #include <afxinet.h> //************************************** // Name: ^!!~ A better HTML Source Grabber/Stealer ~!!^ // Description:Simple example of how to grab(some people like ti call it 'steal') the HTML source of a page from a application... There are a couple of examples here at PSC, but they are not very good because they use ReadHuge to store all of the data in a buffer which can cause memory problems, incomplete page sources, and of course ugly boxes due to no carriage returns or line breaks... This ReadString version is alot more efficent... It works 100% in MFC... And since this code is so easy to implement into virtually any project, I am NOT going to post the project files unless I get alot of requests // By: fritz0x00 (from psc cd) // // // Inputs:None // // Returns:None // //Assumes:Make sure to define m_strURL and m_strSource via ClassWizard // //Side Effects:None //************************************** //** Make sure you add two edit boxes to your dialog, make the one for the URL input a CString named 'm_strURL' //** And to store the source add another edit box(Make sure its multi line), make it a CString named 'm_strSource' void CYourDialogClass::OnYourEvent() { UpdateData(TRUE); //** Perform DDX and get user input CInternetSession session; //** define our internet session CInternetFile* pFile = (CInternetFile *)session.OpenURL(m_strURL); //** define our internet file that will hold the source if(pFile) //** If we can OpenURL(m_strURL) { CString string; //** Create a buffer string while (pFile->ReadString(string) != NULL) //** Read as many string as we can until we run into EOF(End Of File) { m_strSource += string; //** Add the string of data we just read m_strSource += "\r\n"; //** Add a line break to make it look better } } UpdateData(FALSE); }