Link to home
Start Free TrialLog in
Avatar of deadlyfluvirus
deadlyfluvirus

asked on

Visual C++ To Download HTML from a web site...

Hello,
  I am currently a Visual Basic Programmer that is trying to make a long overdue switch to Visual C++.

  I need to set up a MFC app to download the HTML source from a HTTP and a HTTPS website.

  I was able to do this successfully using the MSINET.OCX (Microsoft Internet Transfer Control, v6.0) in Visual Basic.

  Is it possible to conquer this by NOT using an ActiveX control and using a built in C++ class?

  If I cannot use a built in C++ class, then how do I make that ActiveX control work?

Thanks, Christian
ASKER CERTIFIED SOLUTION
Avatar of mnashadka
mnashadka

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deadlyfluvirus
deadlyfluvirus

ASKER

Thanks! That is exactly what I need!

Now...2 Things...
1.) Is there any way that it can download into a string instead of creating a file?

2.)How can I connect to an HTTPS server?

Thanks, Christian
For the string part, you could just be appending each line to a string rather than doing the WriteString, changing:
// Create a new file and dump the results there
     CStdioFile local_file("default.htm", CFile::modeCreate | CFile::modeWrite | CFile::typeText);

     CString str;
     while(file->ReadString(str))
       local_file.WriteString(str);
     local_file.Close(); // Delete the local file

to
    CString total_string, str;
    while(file->ReadString(str))
      total_string += str;

As far as https is concerned, that's much more of an issue.  I can't tell you off of the top of my head how to do that.  You might want to look at the WinInet stuff.  But good luck.
Isn't there a CHttpsConnection?