Solved

C++ Download Web page

Posted on 2008-06-24
3
1,146 Views
Last Modified: 2008-06-25
I have had to make a switch from Visual Basic to C++. I need to make a console application (so no MFC) to download a webpage (just its contents works, too) and save it to a file on the hard drive. I am using Visual Studio 2008 and cannot find an answer via the MSDN.
0
Comment
Question by:ddbrown123
  • 2
3 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 21859200
Take a look at libcurl, a free library for everything HTTP (and more) :

        http://curl.haxx.se/libcurl/

and more specifically this example :

        http://curl.haxx.se/lxr/source/docs/examples/simple.c
0
 
LVL 40

Accepted Solution

by:
evilrix earned 250 total points
ID: 21859866
The WinInet library, which is part of the Windows SDK (and part of the OS) contains all the functions you need to download a web page.

InternetOpen()
Initializes an application's use of the WinINet functions.
http://msdn.microsoft.com/en-us/library/aa385096(VS.85).aspx

InternetOpenUrl()
Opens a resource specified by a complete FTP, Gopher, or HTTP URL.
http://msdn.microsoft.com/en-us/library/aa385098(VS.85).aspx

InternetReadFile()
Reads data from a handle opened by the InternetOpenUrl
http://msdn.microsoft.com/en-us/library/aa385103(VS.85).aspx

InternetCloseHandle()
Closes a single Internet handle
http://msdn.microsoft.com/en-us/library/aa384350(VS.85).aspx
0
 
LVL 40

Expert Comment

by:evilrix
ID: 21859884
>> I need to make a console application (so no MFC) to download
You can write console applications using MFC. The Microsoft Foundation Classes aren't just about writing GUI applications.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now