Load url in C ++

I want to be able to load a url in C ++. Something simple:

std :: string s;
s = download ("http://www.example.com/myfile.html");

Ideally, these would be URLs such as:

I used asio in Boost, but in fact it did not have code to handle protocols like ftp and https. Now I have discovered that QT has more that I need ( http://doc.trolltech.com/2.3/network.html ).

It's tempting to make the switch to Qt, but it seems a bit heavy and crosses many of the Boost features. Is it worth learning another API (Qt) or can Boost do more than I think?

+3
source share
4 answers

Not a direct answer, but you can consider libCURL , which almost exactly describes.

Here are sample applications here , and in particular, this demonstrates how simple the use can be.

+16
source

I would not go to Qt just for network stuff, as that is really not all that impressive; There are many missing parts. I would switch only if you need GUI stuff for which it has a top level.

libCURL is pretty easy to use and more reliable than Qt stuff.

+3
source

Poco Project HTTP FTP ( ). . , .

+2
source

You can use URLDownloadToFile or URLOpenBlockingStream , although cURL, libcurl are suitable tools for this kind of task.

+1
source

Source: https://habr.com/ru/post/1712637/


All Articles