Jump to content
  • Advertisement
Sign in to follow this  
Ey-Lord

How can i download in c++ ?

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys :) I start googling for this, but i cannot find the usefull words .. so i came here . I wana let my program download an html / php file or whatever . ( for exemple , the index.html of a site ) . How can i do that ? Thx .

Share this post


Link to post
Share on other sites
Advertisement
look at the libcurl library. It provides a really easy interface for dealing with HTML/FTP/etc transfers through C++ code: http://curl.haxx.se/libcurl/.

The alternative is a different library or just using sockets programming. The latter isn't actually that bad, but there's a steep learning curve with sockets programming. it's useful to know but a little bit of a bitch to initially learn. But basically you just open up a send socket to the website in question and then send the properly formatted HTML GET/POST/etc string. You can google around for the HTML request formatting specifications.

-me

Share this post


Link to post
Share on other sites
http://msdn.microsoft.com/workshop/networking/moniker/reference/functions/urldownloadtofile.asp

Example:
#include <urlmon.h> //Must add the urlmon.h to project or URLDownloadToFile will not work.

#pragma comment(lib, "urlmon.lib") //Must add the lib file to project or URLDownloadToFile will not work.

int main()

{

HRESULT hr = URLDownloadToFile ( NULL, "http://www.cartoonlarry.com/index.htm", "C:\\cartoonlarry.htm", 0, NULL );

return 0;

}

Hope this helps :)

Share this post


Link to post
Share on other sites
Quote:
Original post by ace_lovegrove
I believe you want to look into a library called WinSock.


libcurl >> Winsock =)

Winsock is the sockets programming stuff i mentioned in the latter of my 2 paragraphs.

-me

Share this post


Link to post
Share on other sites
Eheh, I thought the title said 'How can I download C++'.. Had one of those, 'oh-no, not another' moments [grin] Anyway, you probably want to look into sockets, or a higher level library/wrapper if you don't want to deal with the sockets directly.

Share this post


Link to post
Share on other sites
For sockets, headers etc. can be used in a more crossplatform way using SDL_net, AFAIK. (I certainly use them in my projects, so that it can run on Win/Linux/Mac OSX/FreeBSD without having to enclose #include's in #ifdef's, etc.)

Share this post


Link to post
Share on other sites
thx everyone :)
Hum , i havent learned those "sokets" things again , and havent enought time ;o) atm .
I only wana do ONE task , pretty easy :) i think i can go w/o sokets :)

ill look the libcurl lib tomorow ( 23 p.m here lol) .
and about SDL_net, i may check taht too ! im using SDL§openGL in other project so im quite familliar with this :)

thx again ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!